将表单文本强制为小写 [英] Forcing form text to be lower-case

查看:83
本文介绍了将表单文本强制为小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将username文本中的文本输入强制为小写,而不管用户类型是什么?

How could I force the text in the "username" text input to be lower-case regardless of what user types?

<div class="register">
   <label for="username">Select username:</label>
</div> 
<div class="registerform">
    <input name="username" class="registerfont" type="text"
           id="username" maxlength="15" style="height:35px; width:300px">
</div>


推荐答案

我有一个例子: http://jsfiddle.net/xCfdS/3/

HTML:
< input type =textid =txtonkeyup =return forceLower(this);/>

Javascript:

Javascript:

function forceLower(strInput) 
{
strInput.value=strInput.value.toLowerCase();
}​

这篇关于将表单文本强制为小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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