Javascript Form Verification Regular Expressions
Use a regular expression to determine whether it is a 0-9 Arabic number
CopyCode The Code is as follows: function regisdigit (fdata)
{
VaR Reg = new Regexp ("^ [0-9] $ ");
Return (Reg. Test (fdata ));
}
Use this expression to obtain the string length.Copy codeThe Code is as follows: function regdatalength (fdata)
{
VaR vallength = fdata. length;
VaR Reg = new Regexp ("^ [\ u0391-\ uffe5] $ ");
VaR result = 0;
For (I = 0; I <vallength; I ++)
{
If (Reg. Test (fdata. charat (I )))
{
Result + = 2;
}
Else
{
Result ++;
}
}
Return result;
}
Application expansion determines whether it is a valueCopy codeThe Code is as follows: function regisnumber (fdata)
{
VaR Reg = new Regexp ("^ [-]? [0-9] + [\.]? [0-9] + $ ");
Return Reg. Test (fdata)
}
Verify that email is correctCopy codeThe Code is as follows: function regisemail (fdata)
{
VaR Reg = new Regexp ("^ [0-9a-za-z] + @ [0-9a-za-z] + [\.] {1} [0-9a-za-z] + [\.]? [0-9a-za-z] + $ ");
Return Reg. Test (fdata );
}
Determine whether the mobile phone number is correctCopy codeThe Code is as follows: function regisphone (fdata)
{
VaR Reg =/^ (\ + 86 )? (1 [0-9] {10}) $ /;
Return Reg. Test (fdata );
}