本文介紹了jquery驗證只有數字的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有 jquery.validate.js 插件,它對我來說很好用.
I am having the jquery.validate.js plugin and it is working fine for me.
我的問題是:
我有一個文本框,這個文本框是強制性的,應該只接受數字.
I am having a textbox and this textbox is mandatory and should only accept digits.
在js中,我可以看到有數字驗證,問題是我不知道如何使用它.
In the js, I can see that there is validation for the digits and the problem is that I do not know how to use it.
我只知道如何通過將文本框字段放入<class="required">
I only knew how to make the field required by putting in the textbox field <class="required">
那么,我怎樣才能再添加一個驗證條件來只接受數字.
So, how can I add one more validation criteria to accept only digits.
感謝
推薦答案
檢查一下添加
$("#myform").validate({
rules: {
amount: {
required: true,
digits: true
}
}
});
http://docs.jquery.com/Plugins/Validation/Methods/digits
這篇關于jquery驗證只有數字的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!