jQuery验证字段的范围 [英] jQuery validation field by range

查看:71
本文介绍了jQuery验证字段的范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何按范围验证字段?

我使用其他方法,但我不知道如何通过HTML为我的验证方法提供范围参数。

I use additional-methods, but i don't know how providing parametr with range to my validation method via HTML.

某些东西

< input type =textclass =rangeField =[10, 20]/>

如果我可以在验证中对整数和小数进行区分,那就太好了。

It's nice, if i can make a difference between integer and decimal in validation.

推荐答案

您使用的是验证插件?这个插件可以轻松验证范围。

Are you using the Validation plugin? This plugin makes it trivial to validate against a range.

$("#myform").validate({
  rules: {
    field: {
      required: true,
      range: [13, 23]
    }
  }
});

<input type="text" id="myrange" name="myrange" class="field" />

这篇关于jQuery验证字段的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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