input输入框输入小写字母自动转换成大写字母有两种方法

1.用js onkeyup事件,即时把字母转换为大写字母:

html里input加上

 <input type="text" id="txt1" value="" onkeyup="toUpperCase(this)"/>

js写函数

function toUpperCase(obj)
 {
 obj.value = obj.value.toUpperCase()
 }

这种方法虽然可以,但是输入汉字的时候会受到干扰,还有一种更好的方法

加css

 <input type="text" id="txt1" value="" style="text-transform:uppercase"/>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
  • 2021-11-23
  • 2021-11-23
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2021-12-18
  • 2021-08-04
  • 2022-12-23
  • 2022-01-22
相关资源
相似解决方案