我有 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验证只有数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!