场约束 [英] Field constraint

查看:65
本文介绍了场约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个字段,接收整数最多2位小数,如56.22

该字段不应接受大于999999.99


我们必须限制用户不要在现场的按键事件中输入更多内容。


请帮助......


有效参赛作品

0.22

1.22

100000.99

2.2


无效

0.232 [用户不允许输入小数多于2]

1999999.99


问候,

解决方案

Google for JavaScript模式匹配示例使用正则表达式。


对于所有事情reg-expy, http://www.regular-expressions.info/ 是一个很好的资源。

我已经在使用regex /^([0-9]{0,6} | [0-9] {0,6} \。[0-9] {0,2} )

Hi,

I have a field in form that receive integer upto 2 decimal only like 56.22
The field should not accept greater then 999999.99

and we have to restrict user not to enter more then this on keypress event of field.

Please help...

valid entries
0.22
1.22
100000.99
2.2

Invalid
0.232 [user should not allowed to enter decimal more then 2]
1999999.99

Regards,

解决方案

Google for JavaScript pattern matching examples using regular expressions.


For all things reg-expy, http://www.regular-expressions.info/ is a good resource.


I am already using regex /^([0-9]{0,6}|[0-9]{0,6}\.[0-9]{0,2})


这篇关于场约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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