整数和字符文本框 [英] integer and characters textbox
本文介绍了整数和字符文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要使用整数和字符文本框..应该禁用整数文本框中的字符键..反之亦然,在asp.net中使用vb
我该怎么做..
请引导我..
thnx
i want to use integer and character textbox .. in integer textbox character key should be disabled..and vice versa in asp.net using vb
how i can do it..
plz guide me..
thnx
推荐答案
最简单的方法是用Javascript实现:
Easiest way is to do it in Javascript:
<html>
<head>
<script language=Javascript>
<!--
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
//-->
</script>
</head>
<body>
<input id="tbChar" onkeypress="return isNumberKey(event)" type="text" name="tbChar">
</body>
</html>
仅允许.''0"-"9",并且反向操作非常简单.
That allows ''.'' 0'' - ''9'' only, and it is pretty simple for you to reverse.
您需要的是一种过滤机制文本框.这是一个仅执行此任务的小型javascript框架.检查一下,您应该可以在几分钟内完成您想要的操作.
用于常见验证场景的微型Javascript框架. [ ^ ]
What you need is a filtering mechanism for your textboxes. Here is a small javascript framework to perform this task only. check this out and you should be able to do what you want in minutes.
A Tiny Javascript Framework for Common Validation Scenarios.[^]
尝试使用RegularExpressionValidator,将其放在您的控件中validationexpression ="^ [0-9] {4}
Try using RegularExpressionValidator, put this in your Control validationexpression="^[0-9]{4}
这篇关于整数和字符文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文