允许数字验证,小数点后两位 [英] numeric validation allowed 2 digit after decimal

查看:133
本文介绍了允许数字验证,小数点后两位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#后面的代码处进行的验证仅允许数字值,而在十进制之后仅允许2位数字,并且在文本框中不允许字母数字值

validation at codebehind C# allowed only numeric values & after decimal allowed only 2 digits and not allowed alpha numeric value in textbox

推荐答案

验证的一种替代方法是使用掩码文本框.您也可以在ASP.NET中找到一些内容.

请参阅:
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/MaskedEdit/MaskedEdit.aspx [ ^ ],
http://www.asp.net/community/control-gallery/Item.aspx? i = 387 [ ^ ].

有关jQuery的纯JavaScript解决方案,请参见以下讨论:
http://stackoverflow.com/questions/480979/jquery-masked-input-plugin-select-all-content-when-textbox-receives-focus [ https://github.com/RobinHerbots/jquery.inputmask [ http://www.meiocodigo.com/projects/meiomask/ [
One alternative to validations is a masked text box. You can find some for ASP.NET as well.

Please see:
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/MaskedEdit/MaskedEdit.aspx[^],
http://www.asp.net/community/control-gallery/Item.aspx?i=387[^].

For the pure JavaScript solution with jQuery, please see this discussion:
http://stackoverflow.com/questions/480979/jquery-masked-input-plugin-select-all-content-when-textbox-receives-focus[^].

A couple of jQuery plug-ins you can try:
https://github.com/RobinHerbots/jquery.inputmask[^],
http://www.meiocodigo.com/projects/meiomask/[^].

—SA


将其放入您的头部scipt标签.
这可能对您有帮助....
put this in to your head scipt tag.
this might help you....
var RegularExpression  =  new RegExp(^\d+(\.\d{1,2})?


); 如果(RegularExpression.match(" )) { alert(" ); } 其他 { alert(" ); }
); if (RegularExpression.match("your_number_string")) { alert("Valid Number"); } else { alert("INVALID Number"); }


这篇关于允许数字验证,小数点后两位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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