User input verification function, user verification function

Source: Internet
Author: User

User input verification function, user verification function
// User input verification function
// Name verification
Function checkename (str ){
Var m_name =/^ [\ u4E00-\ u9FA5] {2, 7} $ /;
Return m_name.test (str );
}
// Email Verification
Function checkemail (str ){
Var m_e-mail =/^ ([a-zA-Z0-9 _\. \-]) + \ @ ([a-zA-Z0-9 \-]) + \.) + ([a-zA-Z0-9] {2, 4}) + $ /;
Return m_email.test (str );
}
// Proofread QQ numbers
Function checkqq (str ){
Var m_qq =/^ [1-9] \ d {4, 9} $ /;
Return m_qq.test (str );
}
// ID card verification
Function checkidcard (str ){
Var m_idcard =/^ \ d {15} (\ d {2} [A-Za-z0-9])? $ /;
Return m_idcard.test (str );
}
// Birthday Verification
Function checkbirthday (str ){
Var m_birthday =/^ ((?! 0000) [0-9] {4}-(0 [1-9] | 1 [0-2]) -(0 [1-9] | 1 [0-9] | 2 [0-8]) | (0 [13-9] | 1 [0-2]) -(29 | 30) | (0 [13578] | 1 [02])-31) | ([0-9] {2} (0 [48] | [2468] [048] | [13579] [26]) | (0 [48] | [2468] [048] | [13579] [26]) 00)-02-29) $ /;
Return m_birthday.test (str );
}
// Verify the mobile phone number
Function checkphone (str ){
Var m_phone =/^ 1 [3 | 4 | 5 | 7 | 8] [0-9] {9} $ /;
Return m_phone.test (str );
}
// Postal code verification
Function checkpost (str ){
Var m_post =/^ 1 [3 | 4 | 5 | 7 | 8] [0-9] {9} $ /;
Return m_post.test (str );
}
// Fax Verification
Function checkfax (str ){
Var m_fax =/^ ([0-9] {3, 4 }\-)? ([0-9] {7,8}) (\-[0-9] + )? $ /;
Return m_fax.test (str );
}

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.