User registration information is verified correctly
One, JavaScript way
Second, regular expression validation
Apply Regular expression validation: User name 4-16 bit, beginning of letter ; username 4-16 bit, first letter capitalized ; two times the password is the same; phone number One by one and starting with 1 ; date of birth
in the The register.jsp script section code is as follows
<script language= "JavaScript" type= "Text/javascript" >
function Check ()
{
var Name=document.getelementbyid ("name"). Value;
var patrn_name=/^[a-za-z][a-za-z0-9]{3,15}$/; User name 4-16 bit, beginning of letter
if (name!=null&&!patrn_name.exec (name))
{
Alert (" user name input does not meet the requirements " +name);
return false;
}
var Pass1=document.getelementbyid ("Pass1"). Value;
var patrn_pass=/^[a-z][a-za-z0-9]{3,15}$/; username 4-16 bit, first letter capitalized
if (Pass1!=null&&!patrn_pass.exec (PASS1))
{
Alert (" password input does not meet the requirements , first letter Capital " +pass1);
return false;
}
if (Form1.pass1.value!=form1.pass2.value)
{
Alert (" password is different ");
Form1.pass1.focus ();
return false;
}
var Tel=document.getelementbyid ("Tel"). Value;
var patrn_tel=/^[1][0-9]{10}$/; tel:13562276780
if (tel!=null&&!patrn_tel.exec (tel))
{
Alert ("Tel does not meet the requirements ");
return false;
}
var Csrq=document.getelementbyid ("Csrq"). Value;
var patrn_csrq=/^ (19|20) \d{2}-(1[0-2]|0?[ 1-9])-(0?[ 1-9]| [1-2] [0-9]|3[0-1]) $/; csrq:2012-02-05
if (Csrq!=null&&!patrn_csrq.exec (CSRQ))
{
Alert ("csrq:2012-02-05");
return false;
}
return true;
}
</script>
This article is from the "Learn Without thinking" blog, please be sure to keep this source http://dyzyxy.blog.51cto.com/944775/1652125
JavaScript User registration Information validation