使用JavaScript验证文本框 [英] Validating textbox using javascript

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

问题描述

我有一个名为"txtMoney"的文本框
我想使用javascript验证此文本框.其验证标准如下

*不允许使用负数
*所有数字.没有字母
*小数点后仅两位数字
*最多12位数字,包括十进制


我该怎么做.

I have a textbox named "txtMoney"
I want to validate this textbox using javascript. And its validation criteria are as follows

* Negative number is not allowed
* All numerics. No letters
* Only two digits after decimal
* Maximum 12 digits including decimal


How can i do this.

推荐答案

您可以使用Javascript RegEx验证货币输入(基于文本框名称的假设).快速搜索Google词以揭示给您的内容;
validate-currency-amount-using-regular-expressions-in-javascript [ ^ ]
You can use Javascript RegEx to validate for a currency input (assumption based on name of text box). A quick search of a google term to reveal that gives you;
validate-currency-amount-using-regular-expressions-in-javascript[^]


使用Regex
JavaScript货币验证 [货币格式 [最大长度 [
Using Regex
Javascript Currency Validation[^]

without Regex
Money Format[^]

BTW you may use maxlength[^] Attribute to specify the maximum length of the control.


这篇关于使用JavaScript验证文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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