jquery验证只有数字 [英] jquery validation only digits

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆