2011-05-23 59 views
0

我一直在尋找這個好幾個小時,我想我會問這裏,然後拉我的頭髮。我正在做一個表單驗證。一切都很好,除了一個領域:我確定它是愚蠢的。jquery驗證問題 - 不適用於某個特定字段

<input name="Credit Card Number" style="width:150px;" title="Credit Card Number" id="billingCC" type="text" class="textboxpg2" maxlength="50" autocomplete="off" onKeyUp="highlightCC(this.value);"> 

這是交易。當我只是添加所需的類時,它工作得很好。當我嘗試添加規則時,它沒有發現該字段無效。表格中的其他所有內容,所有其他驗證都可以正常工作。只是這一個。我已經嘗試過沒有onkeyup JavaScript,以確保它不會干擾,而不是問題。請指出我確信我正在犯的愚蠢錯誤。我在錯誤控制檯中沒有收到任何內容,除此之外,表單驗證正常。謝謝!

規則

 billingCC: { 
     required:true, 
     creditcard:true, 
     number: true,   
    }, 

消息

billingCC: "Invalid credit card number", 
+0

對象文字中的尾隨逗號會阻止舊版本的Internet Explorer正常工作。這可能不是問題,但你應該刪除它。 – lonesomeday 2011-05-23 21:08:27

回答

1

的驗證插件使用name屬性,而不是ID,所以它不會發現它。試試這個:

<input name="billingCC" style="width:150px;" title="Credit Card Number" id="billingCC" type="text" class="textboxpg2" maxlength="50" autocomplete="off" onKeyUp="highlightCC(this.value);">