JavaScript Regular verifies that the string is empty
Purpose: Check if the input string is empty or all are spaces
The input quantity is a string: str
Return: Returns True if the input amount is NULL or FALSE
function IsNull (str) {
if (str = "") return true;
var Regu = "^[]+$";
var re = new RegExp (regu);
return Re.test (str);
Regular expression Validation mailbox
JavaScript form verification Email to determine whether an input amount is a mailbox email, implemented through regular expressions.
Check Email mailbox
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 Regular verifies that the input is Chinese
JavaScript form validation is Chinese, determines whether an input is Chinese and is implemented through regular expressions.
JavaScript form validation is Chinese
Check to see if the Chinese
function Ischn (str) {
var reg =/^[u4e00-u9fa5]+$/;
if (!reg.test (str)) {return
false;
}
return true;
}
JavaScript regular verifies different strings of two strings
JavaScript is comparing two strings
JavaScript is comparing two strings,
is to use regular expressions to quickly compare different characters of two strings.
<script language= "JavaScript" >
var str1 = "Find a comparison string processing function";
var str2 = "Seek two or three comparison string processing";
var re = new RegExp (? =.*?) [^ "+ str1 +"] (?=.*?)| (?=.*?) [^ "+ str2
+"] (? =.*?) "," G ");
var arr;
while ((arr = re.exec (str1 + str2))!= null)
{
document.write (arr);
}
</script>
JavaScript Regular verifies the input in Chinese or uppercase letters
JavaScript forms validate Chinese capital letters to determine whether an input is an English letter in Chinese or uppercase, and is implemented through regular expressions.
Check whether it is a valid real name and can only contain Chinese or uppercase English letter
function Isvalidtruename (strName) {
var str = Trim (strName); To determine whether it is all English or Chinese, you can include a space
var reg =/^[a-z u4e00-u9fa5]+$/;
if (Reg.test (str)) {return
false;
}
return true;
}
JavaScript form authentication phone number
The JavaScript form verifies the phone number to determine whether an input is a phone number and is implemented through 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.exec (str);
}
to learn more about the validation problem with JavaScript, click JavaScript Validation