文本框只接受大写字母 [英] textbox wich only accept uppercase letter
本文介绍了文本框只接受大写字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须这样做....
在文本框中我们无法输入数值。如果我输入小写字母,那么它会自动转换为大写如果我输入大写字母然后它可以接受原样。
我必须使用 javascript(解决方案资源管理器中的.js文件)执行此操作
请告诉我怎么做..
I have to do something like that....
In textbox we can not enter numeric value.if I enter lowercase letter then it automatically convert into uppercase letter.And if I enter uppercase letter then it can accept as it is.
I have to do this using javascript (.js file in solution explorer)
please tell me how to do this..
推荐答案
你可以简单地使用在文本框声明中 style =text-transform:uppercase。
示例:
You can simply use style="text-transform:uppercase" in your textbox declaration.
Example :
<asp:TextBox style="text-transform:uppercase" runat="server" ID="myTextBox" />
http://lmgtfy.com/?q=C%23+textbox+which+only+accept+uppercase+letter [ ^ ]
您可以执行大写部分非常简单地使用CSS:
You can do the uppercase part very simply by using CSS:
<input id="myInput" style="text-transform: uppercase" type="text" />
非数字也需要更多复杂性:
The non-numeric as well needs a little more complexity:
<script language="JavaScript">
function noNumerics(evt)
{
var e = event || evt;
var charCode = e.which || e.keyCode;
if ((charCode >= 48) && (charCode <= 57))
return false;
return true;
}
</script>
....
<input id="yourid" style="text-transform: uppercase" type="text" onkeypress="return noNumerics();"/>
功能名称错误![/ edit]
[edit]Wrong name for function![/edit]
这篇关于文本框只接受大写字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文