在javascript中的文本框验证中只有一个小数点 [英] Only one decimal point in text box validation in javascript
本文介绍了在javascript中的文本框验证中只有一个小数点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
java脚本中的文本框验证只有一个小数点。大多数java脚本验证支持多个dot's.please发送给我
解决方案
< blockquote>试试这个: - http://www.sitepoint.com/forums/showthread .php?797117-1-Decimal-Validation [ ^ ]
试试这个:
Javascript:
function checkDec(el){
var ex = / ^ [0-9] + \ [0-9] *
/。?;
if (ex.test(el.value)== false ){
alert(' 不正确的数字');
}
}
HTML:
< asp:textbox id = text1 runat = 服务器 onblur = checkDec(this); / < span class =code-keyword>>
--Amit
Hi
Only one decimal point in text box validation in java script.Most java script Validation support multiple dot's.please send me
解决方案
Try this one :- http://www.sitepoint.com/forums/showthread.php?797117-1-Decimal-Validation[^]
Try this:
Javascript:
function checkDec(el){ var ex = /^[0-9]+\.?[0-9]*
/; if(ex.test(el.value)==false){ alert('Incorrect Number'); } }
HTML:
<asp:textbox id="text1" runat="server" onblur="checkDec(this);" />
--Amit
这篇关于在javascript中的文本框验证中只有一个小数点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文