通过判断ASCII值可限制一些字符和符号的输入,比如只能输入数字和“.”:
<asp:TextBox ID="TxtGuaranteeEndDate2" runat="server" Width="141px"
onkeypress="onlyNumericAndDot()" Style="ime-mode: disabled"></asp:TextBox>
js代码
1 //验证只能为数字和.
2 function onlyNumericAndDot()
3 {
4 if(window.event.keyCode != 46)
5 {
6 if ( !(((window.event.keyCode >= 48) && (window.event.keyCode <= 57)) || (window.event.keyCode == 13) || (window.event.keyCode == 46)))
7 {
8 window.event.keyCode = 0 ;
9 }
10 }
11 }
并且要补上Style="ime-mode: disabled",此属性是屏蔽输入法切换