Copy Code code as follows:
<script type= "Text/javascript" >
Verifying generic domain name verification
function Checkneturl () {
var neturl = document.getElementById ("Neturl");
Verify generic domain names such as www.baidu.com
var regstr= "^" ([a-za-z0-9-]+\\.) {1,} (COM|NET|EDU|MIZ|BIZ|CN|CC) $ ";
var re=new RegExp (REGSTR); To create a regular expression object
var re=/^ ([a-za-z0-9-]+\\.) {1,} (COM|NET|EDU|MIZ|BIZ|CN|CC) $/;
if (!re.exec (Neturl.value)) {//Verify that the string entered conforms to the rule
Alert ("The site URL you entered is incorrect!") Correct format such as mail.brookes.com ");
Neturl.focus ();
Return
}
}
Phone check
function Iphoneregexp () {
var iphone= document.getelementbyid ("iphone"). Value;
var regstr= "^ ((13[0-9)) | ( 14[0-9]) | (15[^4,\\d]) | (18[0-9]) \\d{8}$ ";
var re=new RegExp (REGSTR);
if (!re.test (iphone)) {
Alert ("Specification error, correct format such as 152636363** (or cell phone number starting with 13,14,18)");
}
}
Mailbox Checksum (there is a bug)
/*function Emailregexp () {
var email= document.getelementbyid ("email"). Value;
var regstr= "^" ([a-za-z0-9\u4e00-\u9fa5]*[-_]?[ A-za-z0-9]) {1,}+@ ([a-za-z0-9]*[-_]?[ a-za-z0-9]+) +[\\.] [A-za-z] {2,3} ([\\.] [A-za-z] {2})? $";
var re=new RegExp (REGSTR);
if (!re.test (email)) {
Alert ("Specification error, correct format such as 152636363** (or cell phone number starting with 13,14,18)");
Iphone.focus ();
}
}*/
ID Check
function Cardregexp () {
var card= document.getElementById ("card"). Value;
var regstr= "(^\\d{15}$) | (^\\d{18}$) | (^\\d{17} (\\d| X|X) $) ";
var re=new RegExp (REGSTR);
if (!re.test (card)) {
Alert ("Input is not valid, the correct format is: 4101821897020356**");
}
}
Hong Kong and Macao provinces certificate
function Gangaocardregexp () {
var card= document.getElementById ("card"). Value;
var regstr= "[A-z]{1,2}[0-9]{6}[(]{1}[a-z0-9]{1}[)]{1}";
var re=new RegExp (REGSTR);
if (!re.test (card)) {
Alert ("Hong Kong and Macao identity card input illegal!") Correct format such as: a15263* (E) ");
}
}
Disability Certificate
function Canjicardregexp () {
var card= document.getElementById ("card"). Value;
var regstr= "(^\\d{22}$) | (^\\d{20}$) ";
var re=new RegExp (REGSTR);
if (!re.test (card)) {
Alert ("Invalid entry of disability certificate!");
}
}
Zip code
function Postcardregexp () {
var postcard= document.getElementById ("postcard"). Value;
var regstr= "^[0-9]{6}$";
var re=new RegExp (REGSTR);
if (!re.test (postcard)) {
Alert ("Input is illegal!") Correct format such as 4500! ");
}
}
Fax and fixed telephone verification
function Telregexp () {
var tel= document.getElementById ("tel"). Value;
var regstr= "(^\\d{11}$) | ( ^\\d{12}$)) | (^\\d{3}-\\d{8}$) | (^\\d{4}-\\d{7}$) | (^\\d{4}-\\d{8}$) ";
var re=new RegExp (REGSTR);
if (!re.test (tel)) {
Alert ("Writing format is wrong!") Proper format such as 0511-44052** or 021-878888** ");
}
}
The user's famous school, the rules are as follows:
Match account number is legal (start letter, allow 5-16 bytes, allow alphanumeric underline
function Usernameregexp () {
var username= document.getelementbyid ("UserName"). Value;
var regstr= "^[a-za-z][a-za-z0-9_]{3,15}$";
var re=new RegExp (REGSTR);
if (!re.test (UserName)) {
Alert ("Must start with a letter, followed by 4-15 digits, letters or underscores!") ");
}
}
Checksum integer
function Numregexp () {
var num= document.getelementbyid ("num"). Value;
var regstr= "^[0-9]*[1-9][0-9]*$";
var re=new RegExp (REGSTR);
if (!re.test (num)) {
Alert ("Fill in format error, correct format such as: 8080");
}
}
Verify Decimal or integer
function Numfontregexp () {
var num= document.getelementbyid ("num"). Value;
var regstr= "^ ([0]{1,}) | ( [0-9] {1,}) [.] {1} [0-9] {1,}) | [0-9] {1,}$ ";
var re=new RegExp (REGSTR);
if (!re.test (num)) {
Alert ("Fill in the wrong format, correct format 12.3");
}
}
Verifying special characters ^[^%$&@]{1,}$
function Strregexp () {
var str= document.getelementbyid ("str"). Value;
var regstr= "^[^%$&@]{1,}$";
var re=new RegExp (REGSTR);
if (!re.test (str)) {
Alert ("Cannot contain special characters");
}
}
Verify real name
function Nameregexp () {
var name= document.getElementById ("name"). Value;
var regstr= "((^[a-za-z]{1} ([A-za-z_]) {2,20}) | ( ^[\U4E00-\U9FA5]{1}+[A-ZA-Z0-9\U4E00-\U9FA5]{1,14})) $ ";
var re=new RegExp (REGSTR);
if (!re.test (name)) {
Alert ("Shall be 2-15 Chinese characters or 3-21 English letters");
}
}
Verify Passport
function Huzhoaregexp () {
var huzhao= document.getelementbyid ("Huzhao"). Value;
var regstr= "^" ((14) | ( 15) [0-9]{7}] | (g| s| D[0-9]{8}) | ((P.) | (S.) [0-9] {7}) $";
var re=new RegExp (REGSTR);
if (!re.test (Huzhao)) {
Alert ("Passport input is not valid, the correct format such as: G00106556");
}
}
Officer Certificate
function Junguanregexp () {
var junguan= document.getelementbyid ("Junguan"). Value;
var regstr= "^[\u4e00-\u9fa5]{1}\\d{7}$";
var re=new RegExp (REGSTR);
if (!re.test (Junguan)) {
Alert ("Input is illegal!") Correct format such as: Sea 6042** ");
}
}
Verification of civilian cadres
function Junguanregexp () {
var wenzhi= document.getelementbyid ("Wenzhi"). Value;
var regstr= "^[\u4e00-\u9fa5]{1} Wen \\d{4,12}$";
var re=new RegExp (REGSTR);
if (!re.test (Wenzhi)) {
Alert ("Civilian cadre certificate input illegal!") Correct format such as: Guangwen 0816** ");
}
}
Soldier Card
function Shibingregexp () {
var shibing= document.getelementbyid ("shibing"). Value;
var regstr= "^[\u4e00-\u9fa5]{1,3}\\d{4,12}$";
var re=new RegExp (REGSTR);
if (!re.test (shibing)) {
Alert ("Soldier card input is illegal!") Correct format such as: E 176340** ");
}
}
Cell phone and fixed telephone check
function Iphonetelregexp () {
var iphonetel= document.getelementbyid ("Iphonetel"). Value;
var regstr= "((^\\d{11}$) | ( ^\\d{12}$)) | (^\\d{3}-\\d{8}$) | (^\\d{4}-\\d{7}$) | (^\\d{4}-\\d{8}$)) | (^ (13[0-9]) | (14[0-9]) | (15[^4,\\d]) | (18[0-9]) \\d{8}$) $ ";
var re=new RegExp (REGSTR);
if (!re.test (Iphonetel)) {
Alert ("phone number written incorrectly, do not conform to phone number specifications (such as 0511-4405xxx or 15236565xxx), please fill in");
}
}
</script>