/ Programming / 網頁/網站程式 / JavaScript /

JS 正規化表示法做資料驗證

New Subject
Random
Previous
Next
|
JS 正規化表示法做資料驗證

身份證字號正規化驗證
  1. function checkID(string) {
  2.   re = /^[A-Z]\d{9}$/;
  3.   if (re.test(string)) return true;
  4.   }

信用卡號正規化驗證
  1. function checkCreditCard(string) {
  2.   re = /^\d{4}-\d{4}-\d{4}-\d{4}$/;
  3.   if (re.test(string)) return true;
  4.  }

英文名稱正規化驗證
  1. function checkEnglishName(string) {
  2.   re1 = /^[A-Za-z\-]+\s+[A-Za-z\-]+$/;
  3.   re2 = /^[A-Za-z\-]+\s+[A-Za-z\-]+\s+[A-Za-z\-]+$/;
  4.   if (re1.test(string) || re2.test(string)) return true;
  5.   } 

Email 正規化驗證
  1. function checkEmail(string) {
  2.   re = [url=]/^.+@.+\..{2,3}$/[/url];
  3.   if (re.test(string))return true;
  4.   }

  • Keywords : string, return, function, 正規化驗證, checkID, checkEmail, checkCreditCard, Email
0 0
2010-05-08T04:07:00+0000


  • Now, you can post comments by Facebook Account when your Yampiz account was logout or unvariable. whatever, we suggest to post comment by Yampiz Account to get more bounds to join new events of Heyxu
Comment
 
Verify

Archive DIR

    Facebook Page

    QR-Code and APP Launcher

    User Guide
    This Webpage

    In those service tabs, "Scan QRCode, in mobile device" or "Click the button, in this device" to open webpage or APP-related operations.
    QRCode
    • Auto Platform
      For better browsing experience, it will auto detects your device to display webpage.
    • Bug Report
      Tell us about the idea, problem and errors you found.
    • Comodo Secure
      The sensitive data transmission adopts by SSL-2048 authenticated encryption.
    • Copyright
      © 2009 YamPiz Digital Inc. & Jaby Group. All rights reserved.
    • Revised Version
      V2.2.207
      06 Jan 2025 (GMT+8)