Jquery validate Verification

Source: Internet
Author: User

I did a registration page verification in the past two days, but I did not have a good hold on the page's div + css and jquery, so I spent more time.
 
The verification code is as follows:
[Javascript]
<Script type = "text/javascript" src = "<% = path %>/js/jquery-1.4.4.min.js"> </script>
<Script type = "text/javascript" src = "<% = path %>/js/jquery. validate. js" charset = "UTF-8"> </script>
<Script type = "text/javascript">
Function checkName (){
// The server responds with text
$. Ajax ({www.2cto.com
// Request type, including GET or POST
Type: "POST ",
// Request url
Url: "registerAction! Register. action? AjaxUrl = 1 & username = "+ $ (" # name "). val (),
// Send data to the service
Data: "ajaxUrl = 1 & username =" + $ ("# name"). val (),
// Server response client output type, text, html, xml, json
DataType: "text ",
// Callback method when the server successfully responds to the client
Success: function (msg ){
$ ("# Namespan" cmd.html (msg );
}
});
}

$ (Function (){
$ ("# UserRegister"). validate ({
/* ErrorLabelContainer: "# messageBox", // container ID that displays the error message
Wrapper: "li", // container containing each error message */
Rules :{
Username :{
Required: true
},
Password :{
Required: true,
Minlength: 6
},
Confirm_pwd :{
Required: true,
Failed to: "# password"
},
Realname :{
Required: true,
Minlength: 2,
Maxlength: 6
},
Phone :{
Required: true,
Maxlength: 11,
Minlength: 11
},
Address :{
Required: true
}
,
Post :{
Required: false,
Maxlength: 6,
Minlength: 6
},
Email :{
Required: false,
Email: true
},
Qq :{
Required: false,
Digits: true
}
//,
// CheckCode :{
// Required: true,
// Digits: true
//}
//,
// F2sfzh :{
/// * Digits: true,
// Rangelength: [18, 20] */
// Required: true,
// IsIdCardNo: true
//}, F2csrq :{
// Required: true,
// Date: true
//}
},
Messages :{
Username :{
Required: "* enter an account"
},
Password :{
Required: "* enter the password ",
Minlength: "* The length cannot be less than 6 characters"
},
Confirm_pwd :{
Required: "* enter the password again ",
Failed to: "* inconsistent passwords"
},
Realname :{
Required: "* name cannot be blank ",
Minlength: "* The length cannot be less than 2 characters ",
Maxlength: "* The length cannot exceed 5 characters"
},
Phone :{
Required: "* the phone number cannot be blank ",
Maxlength: "* the telephone number cannot exceed 11 ",
Minlength: "* incorrect Phone Number Format"
},
Address :{
Required: "* enter the address"
}
,
Post :{
// Required: "the ZIP Code cannot be blank ",
Maxlength: "* zip code can only be 6 digits ",
Minlength: "* zip code can only be 6 digits"
},
Email :{
// Required: "the email address cannot be blank"
Email: "* enter the correct email, such as: 123456@136.com"
},
Qq :{
// Required: "qq cannot be blank ",
Digits: "* QQ numbers can only be numbers"
}
//,
// CheckCode :{
// Required: "The Verification Code cannot be blank"
//}
//,
// F2sfzh :{
/// * Digits: "the ID card number can only be a number ",
// Rangelength: "The length of the ID number is 18 ~ 20 characters "*/
// Required: "Enter your ID card number ",
// IsIdCardNo: "Incorrect ID card number"
//}, F2csrq :{
// Required: "Enter the Date of Birth ",
// Date: "The date format is incorrect (for example, 2009/04/07 )"
//},
}
});
});
</Script>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.