javascript-Simple Page Input control

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.