Javascript Form Verification age
The javascript form verifies the age and determines whether an input value conforms to the age by using a regular expression.
// Check the age
Function isage (STR ){
VaR mydate = new date;
VaR now = mydate. getfullyear ();
If (STR <now-60 | STR> now-18 ){
Return false;
}
Return true;
}
Regular Expression verification email
The javascript form verifies the email and determines whether an input is an email address using a regular expression.
// Check the email address
Function isemail (STR ){
VaR Reg =/^ ([a-zA-Z0-9 _-]) + @ ([a-zA-Z0-9 _-]) + ((\. [a-zA-Z0-9 _-] {2, 3}) {1, 2}) $ /;
Return Reg. Test (STR );
}
Javascript Form Verification uppercase letters
The javascript form verifies Chinese uppercase letters and determines whether an input is a Chinese or uppercase English letter, which is implemented through a regular expression.
// Check whether the name is a valid real name. It can only contain Chinese or uppercase English letters.
Function isvalidtruename (strname ){
VaR STR = trim (strname); // determines whether it is in uppercase or in Chinese. It can contain spaces.
VaR Reg =/^ [A-Z u4E00-u9FA5] + $ /;
If (Reg. Test (STR )){
Return false;
}
Return true;
}
Javascript Form Verification for Chinese
The javascript form verifies whether the input value is Chinese and whether the input value is Chinese. It is implemented through a regular expression.
// Check for Chinese Characters
Function ischn (STR ){
VaR Reg =/^ [u4E00-u9FA5] + $ /;
If (! Reg. Test (STR )){
Return false;
}
Return true;
}
Javascript Form Verification phone number
The javascript form verifies the phone number and determines whether the input is a phone number. This is implemented using a regular expression.
// Check the phone number
Function istel (STR ){
VaR Reg =/^ ([0-9] | [\-]) + $/g;
If (Str. Length <7 | Str. length> 18 ){
Return false;
}
Else {
Return reg.exe C (STR );
}
}