jquery validation only digits(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验证只有数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:jquery验证只有数字


基础教程推荐
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01