我有 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模板网!
用于创建头像的 jQuery/JavaScript 库?jQuery/JavaScript Library for avatar creation?(用于创建头像的 jQuery/JavaScript 库?)
如何做以下掩码输入问题?How to do following mask input problem?(如何做以下掩码输入问题?)
使用 DropKick Javascript 设置值/标签的问题Issues Setting Value/Label Using DropKick Javascript(使用 DropKick Javascript 设置值/标签的问题)
如何对 jquery 插件中的私有方法进行单元测试?how to unit-test private methods in jquery plugins?(如何对 jquery 插件中的私有方法进行单元测试?)
stellar.js - 为垂直滚动网站配置偏移量/对齐元素stellar.js - configuring offsets / aligning elements for a vertical scrolling website?(stellar.js - 为垂直滚动网站配置偏移量/对齐元素?)
jQuery 屏蔽输入插件.当文本框获得焦点时选择所有jQuery masked input plugin. select all content when textbox receives focus(jQuery 屏蔽输入插件.当文本框获得焦点时选择所有内容)