Use regular expressions to determine whether it is an Arabic number of 0-9
function regIsDigit(fData)
{
var reg = new RegExp("^[0-9]$");
return ((fData));
}
Use this expression to get the length of the string
function regDataLength(fData)
{
var valLength = ;
var reg = new RegExp("^[\u0391-\uFFE5]$");
var result = 0;
for(i=0; i< valLength; i++)
{
if(((i)))
{
result += 2;
}
else
{
result ++;
}
}
return result;
}
Apply extension to determine whether it is a numeric value
function regIsNumber(fData)
{
var reg = new RegExp("^[-]?[0-9]+[\.]?[0-9]+$");
return (fData)
}
Verify that the email is correct
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 (fData);
}
Determine whether the mobile phone number is correct
function regIsPhone(fData)
{
var reg = /^(\+86)?(1[0-9]{10})$/;
return (fData);
}
// Determine whether the input is a string composed of 0-9 / A-Z / a-z
function isalphanumber(str)
{
var result=(/^[a-zA-Z0-9]+$/);
if(result==null) return false;
return true;
}
// Determine whether the input is a number-(number contains decimals)-
function isnumber(str)
{
return !isNaN(str);
}
// Determine whether the input is an integer
function isint(str)
{
var result=(/^(-|\+)?\d+$/);
if(result==null) return false;
return true;
}
// Determine whether the input is valid long date format - "YYYY-MM-DD HH:MM:SS" || "YYYY/MM/DD HH:MM:SS"
function isdatetime(str)
{
var result=(/^(\d{4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/);
if(result==null) return false;
var d= new Date(result[1], result[3]-1, result[4], result[5], result[6], result[7]);
return (()==result[1]&&(()+1)==result[3]&&()==result[4]&&()==result[5]&&()==result[6]&&()==result[7]);
}
// Check whether it is YYYY-MM-DD || YYYY/MM/DD date format
function isdate(str){
var result=(/^(\d{4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
if(result==null) return false;
var d=new Date(result[1], result[3]-1, result[4]);
return (()==result[1] && ()+1==result[3] && ()==result[4]);
}
// Determine whether the input is valid for email
function isemail(str)
{
var result=(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/);
if(result==null) return false;
return true;
}
// Remove the spaces at the beginning and end of the string
function trim(str){
return (/(^\s*)|(\s*$)/g, "");
}
// Return the actual length of the string, one Chinese character calculates 2 lengths
function strlen(str){
return (/[^\x00-\xff]/g, "**").length;
}
//Match the Chinese postal code (6 digits)
function ispostcode(str)
{
var result=(/[1-9]\d{5}(?!\d)/);
if(result==null) return false;
return true;
}
//Match domestic phone number (0511-4405222 or 021-87888822)
function istell(str)
{
var result=(/\d{3}-\d{8}|\d{4}-\d{7}/);
if(result==null) return false;
return true;
}
//Check whether it is an integer (0-10000)
function isint1(str)
{
var result=(/^[0-9]$|^([1-9])([0-9]){0,3}$|^10000$/);
if(result==null) return false;
return true;
}
//Match Tencent QQ number
function isqq(str)
{
var result=(/[1-9][0-9]{4,}/);
if(result==null) return false;
return true;
}
//Match ID card (15 or 18)
function isidcard(str)
{
var result=(/\d{15}|\d{18}/);
if(result==null) return false;
return true;
}
//Check whether the text is empty
function checknull(field,sval)
{
if ( =="")
{
alert("Please fill in" + sval + "!");
();
return false;
}
return true;
}
//Mask input characters
function checkChar()
{
var keycode = ;
if(!(keycode>=48&&keycode<=57))
{
return false;
}
}
Copy the codeThe code is as follows:
function regIsDigit(fData)
{
var reg = new RegExp("^[0-9]$");
return ((fData));
}
Use this expression to get the length of the string
Copy the codeThe code is as follows:
function regDataLength(fData)
{
var valLength = ;
var reg = new RegExp("^[\u0391-\uFFE5]$");
var result = 0;
for(i=0; i< valLength; i++)
{
if(((i)))
{
result += 2;
}
else
{
result ++;
}
}
return result;
}
Apply extension to determine whether it is a numeric value
Copy the codeThe code is as follows:
function regIsNumber(fData)
{
var reg = new RegExp("^[-]?[0-9]+[\.]?[0-9]+$");
return (fData)
}
Verify that the email is correct
Copy the 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 (fData);
}
Determine whether the mobile phone number is correct
Copy the codeThe code is as follows:
function regIsPhone(fData)
{
var reg = /^(\+86)?(1[0-9]{10})$/;
return (fData);
}
// Determine whether the input is a string composed of 0-9 / A-Z / a-z
Copy the codeThe code is as follows:
function isalphanumber(str)
{
var result=(/^[a-zA-Z0-9]+$/);
if(result==null) return false;
return true;
}
// Determine whether the input is a number-(number contains decimals)-
Copy the codeThe code is as follows:
function isnumber(str)
{
return !isNaN(str);
}
// Determine whether the input is an integer
Copy the codeThe code is as follows:
function isint(str)
{
var result=(/^(-|\+)?\d+$/);
if(result==null) return false;
return true;
}
// Determine whether the input is valid long date format - "YYYY-MM-DD HH:MM:SS" || "YYYY/MM/DD HH:MM:SS"
Copy the codeThe code is as follows:
function isdatetime(str)
{
var result=(/^(\d{4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/);
if(result==null) return false;
var d= new Date(result[1], result[3]-1, result[4], result[5], result[6], result[7]);
return (()==result[1]&&(()+1)==result[3]&&()==result[4]&&()==result[5]&&()==result[6]&&()==result[7]);
}
// Check whether it is YYYY-MM-DD || YYYY/MM/DD date format
Copy the codeThe code is as follows:
function isdate(str){
var result=(/^(\d{4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
if(result==null) return false;
var d=new Date(result[1], result[3]-1, result[4]);
return (()==result[1] && ()+1==result[3] && ()==result[4]);
}
// Determine whether the input is valid for email
Copy the codeThe code is as follows:
function isemail(str)
{
var result=(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/);
if(result==null) return false;
return true;
}
// Remove the spaces at the beginning and end of the string
Copy the codeThe code is as follows:
function trim(str){
return (/(^\s*)|(\s*$)/g, "");
}
// Return the actual length of the string, one Chinese character calculates 2 lengths
Copy the codeThe code is as follows:
function strlen(str){
return (/[^\x00-\xff]/g, "**").length;
}
//Match the Chinese postal code (6 digits)
Copy the codeThe code is as follows:
function ispostcode(str)
{
var result=(/[1-9]\d{5}(?!\d)/);
if(result==null) return false;
return true;
}
//Match domestic phone number (0511-4405222 or 021-87888822)
Copy the codeThe code is as follows:
function istell(str)
{
var result=(/\d{3}-\d{8}|\d{4}-\d{7}/);
if(result==null) return false;
return true;
}
//Check whether it is an integer (0-10000)
Copy the codeThe code is as follows:
function isint1(str)
{
var result=(/^[0-9]$|^([1-9])([0-9]){0,3}$|^10000$/);
if(result==null) return false;
return true;
}
//Match Tencent QQ number
Copy the codeThe code is as follows:
function isqq(str)
{
var result=(/[1-9][0-9]{4,}/);
if(result==null) return false;
return true;
}
//Match ID card (15 or 18)
Copy the codeThe code is as follows:
function isidcard(str)
{
var result=(/\d{15}|\d{18}/);
if(result==null) return false;
return true;
}
//Check whether the text is empty
Copy the codeThe code is as follows:
function checknull(field,sval)
{
if ( =="")
{
alert("Please fill in" + sval + "!");
();
return false;
}
return true;
}
//Mask input characters
Copy the codeThe code is as follows:
function checkChar()
{
var keycode = ;
if(!(keycode>=48&&keycode<=57))
{
return false;
}
}