JavaScript Form Validation Regular expression encyclopedia
Using regular expressions to determine whether the Arabic numerals are 0-9
Copy Code code as follows:
function Regisdigit (fdata)
{
var reg = new RegExp ("^[0-9]$");
Return (Reg.test (fdata));
}
Use this expression to get the length of the string
Copy Code code 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;
}
Apply an extension to determine whether a value
Copy Code code as follows:
function Regisnumber (fdata)
{
var reg = new RegExp ("^[-]?[ 0-9]+[\.]? [0-9]+$ ");
Return Reg.test (Fdata)
}
Verify that the email is correct
Copy Code code 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 if the phone number is correct
Copy Code code as follows:
function Regisphone (fdata)
{
var reg =/^ (\+86)? (1[0-9]{10}) $/;
Return Reg.test (Fdata);
}