2013-07-08 71 views
1

的特定密碼要求我使用jQuery驗證引擎,並希望能找到一個自定義[密碼時應]邏輯,我可以添加到jquery.validationEngine-en.js將一次性檢查多個條件(要求:9個MinChars,1個UpperCase,1個LowerCase,1個數字和1個SpecialChar)。我甚至都不瞭解JavaScript,甚至無法嘗試此操作。我已經搜查過,並且感到驚訝,它並不在那裏。可能它必須是許多個人的?像minSize屬性和最大範圍在定製validatation爲公司

input type="password" name="password1" id="password1" size="44" maxlength="44" 
     class="validate[required,minSize[8],maxSize[10],custom[password]]" 

一起使用,這是電子郵件檢查

"email": { 
    "regex": /^(([^<>()[\]\\.,;:\[email protected]\"]+(\.[^<>()[\]\\.,;:\[email protected]\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, 

    "alertText": "* Invalid email address" 

會是什麼PASSWORD一個樣子?

"password": { 

    "regex":   , 

    "alertText": "* Invalid password" 

我會非常喜歡它,以警惕的是沒有被輸入(即:)沒有大寫字母,沒有數字小,無Spcecial性格等
由於提前specifc項目

回答

2

那麼,受火的洗禮,但是完成了。我不得不分解這些,這實際上是我想要做的,因此單個的警報文本可以用於所需的不同標準,而不是一個通用的無效密碼消息。隨着regexlib.com的幫助下,我能夠添加大量的自定義校驗內jquery.validationEngine-en.js的minSize[n]required已經內置到jQuery驗證,所以不顯示這些。

  "minLowerAlphaChars": { 
       // requires at least one lower case alpha character 
       "regex": /^(.*[a-z].*)/, 
       "alertText": "* Must include 1 lowercase character" 
      }, 
      "minUpperAlphaChars": { 
       // requires at least one UPPER case alpha character 
       "regex": /^(.*[A-Z].*)/, 
       "alertText": "* Must include 1 uppercase character" 
      }, 
      "minSpecialChars": { 
       // requires at least one SPECIAL character of the list in regex 
       "regex": /^(?=.*[[email protected]#$%&*()_+}])/, 
       "alertText": "* Must include 1 special character" 
      }, 
      "minNumberChars": { 
       // requires at least one NUMERIC 
       "regex": /^(?=.*\d)/, 
       "alertText": "* Must include 1 numberic" 
      }, 
      "noFirstNumber": { 
       // requires first charecter NOT be NUMERIC 
       "regex": /^(?!\d)/, 
       "alertText": "* First Character can not be numberic" 
      }, 

用法; <input type="password" class="validate[required,minSize[8],custom[minNumberChars],custom[minSpecialChars],custom[noFirstNumber],custom[minUpperAlphaChars],custom[minLowerAlphaChars]]" name="password1" id="password1" size="44">