如何为此表单插件编写正则表达式
我正在使用此表单插件,它也可以接受正则表达式进行验证 http://www. position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/ 我正在寻找正则表达式验证,其中用户可以输入 1 到 250 之间的值。 它也不能接受“0”。以下不允许有特殊字符,也不能有负数,例如-1 -2 -3等 这是它可以接受的形式 "/^[1-9][0-9]?$/"
iam using this form Plugin which can also Accept regex for validation
http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/
Iam looking for Regex Validation where the User can enter the value between 1 and 250 .
it cannot accept "0" also .The following should not be allowed no speacial characters and as well as no negative number such as -1 -2 -3 and so on
this is the form which it can accept "/^[1-9][0-9]?$/"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查值是否在给定范围内并不是使用正则表达式的典型场景。您可以这样做,但该插件似乎还支持自定义验证功能,在这种情况下我更喜欢这种功能,因为它们更容易阅读和理解。验证任务的自定义函数如下所示:
checking if a value is in a given range is not a typical scenario for the use of regular expressions. You could do that, but the plugin also seems to support custom validation functions which i would prefer in this case, because they are easier to read and understand. A custom function for your validation task would look like this: