1. The name can only be Chinese characters
var namecheck =/^[\u4e00-\u9fa5]{2,21}$/;if (!namecheck. Test (name)) { alert ("Input ' name ' contains non-kanji characters!"); return false; }
2. Simple ID Check (check content including number, number of digits, and x,x at the end)
var Idnocheck =/(^\d{15}$) | (^\d{18}$) | (^\d{17} (\d| X|X) $)/;if (!idnocheck. Test (Idno)) { alert ("Entered ' ID number ' is not legal!"); return false; }
3. Simple Mobile phone number check (number second can refer to carrier-defined number segment)
var Phonenocheck =/^ (1[0-9]{10}) $/;if (!phonenocheck. Test (Phoneno)) {alert ("The input ' mobile number ' is illegal!"); return false;}
4. Simple address anti-special character check
var specialkey = "[' ~!$^&* () =|{} ':; ' \\[\\].<>/?~! ¥......&* ()--| {}【】‘;:”“‘。 、? ] "";//Remove # and, for (var i = 0; i < specialkey.length; i++) {if (Address.indexof (specialkey[i])! =-1) {alert ("The input ' address ' contains illegal characters !"); return false; } }
5. Special keying prohibited input
function Checkkeys () { if (Event.keycode > && event.keycode <) | | (Event.keycode > && event.keycode < $) | | (Event.keycode > && event.keycode <) ) { event.returnvalue = false; } }
KeyCode I will not swim, already have a lot of great God wrote related articles, I picked the easy combat in the use of an article, please refer to the link
Https://www.cnblogs.com/daysme/p/6272570.html
javascript-Simple Page Input control