<script>
function checkVal(txt)
{
val = txt.value
str = ""
for ( i = 0; i < val.length; i++ ) {
chr = val.charAt(i)
asc = chr.charCodeAt()
if (asc < 123 && asc > 96)
{
chr = String.fromCharCode(asc-32)
}
str += chr;
}
txt.value=str
}
</script><input type="text" onChange="checkVal(this)" name="Answer" size="15">以上是一个实现,当失去焦点的时候,会把文本框里的小写字母转换为大写

解决方案 »

  1.   

    失去焦点,我觉得最好还是用onBlur事件。
    onChange好像执行次数比较多吧
      

  2.   

    <input type="text" onblur="this.value=this.value.toUpperCase()" name="Answer" size="15">
      

  3.   

    <input type="text" onblur="this.value=this.value.toUpperCase()" name="Answer" size="15">
      

  4.   

    weidegong(weidegong):
    谢谢,这么简单就完成了
      

  5.   

    有现成的方法不用? zhjx_10(色子)你的方法也不错嘛。