2013-07-19 63 views
0

有誰知道爲什麼這個驗證不起作用,我試圖執行8-12個字符的alphnumeric輸入但沒有任何事情發生,我已經鏈接到外部jquery表單驗證庫,你可以看到:jquery表單驗證 - 強制執行alphnumeric

<form id="userTest">  
    <table> 
    <tr> 
    <td>Password</td><td><input type="password" id="pwd"></input></td> 
    </tr> 
</table> 
</form> 

jQuery的:

$(function(){ 
    $("form#userTest").validate({ 
     rules:{ 
       pwd:{ 
        alphanumeric: true, 
        minlength: 8, 
        maxlength: 12  
       } 
     } 
    }); 
}); 

http://jsfiddle.net/zCjav/

謝謝,

Alan。

回答

1

你缺少additional-methods.js文件,其中添加了字母數字的規則,你也可能需要添加必要的驗證

jQuery(function ($) { 
    $("form#userTest").validate({ 
     rules:{ 
      pwd:{ 
       required: true, 
       alphanumeric: true, 
       minlength: 8, 
       maxlength: 12  
      } 
     } 
    }); 
}); 

演示:Fiddle

+0

感謝多麼愚蠢的錯誤在我的部分。我不相信我曾經必須在PHP中編寫我自己的驗證代碼。這很容易。 –

+0

Alan,您仍然希望在PHP中進行驗證 - 在用戶的瀏覽器中很容易禁用Javascript! – Ryley