How to make everything in a textfield be capital letters / uppercase?

后端 未结 5 704
不知归路
不知归路 2021-02-07 02:37

I want to make everything I write in a textfield to be capital letters. As I write, not after losing focus.

How do I do this using jQuery?

5条回答
  •  遇见更好的自我
    2021-02-07 03:07

    Use
    oninput='this.value=this.value.toUpperCase();
    This event is just for such cases, is fired after user input (pressing key) but before updating (displaying value), so with this typed text won't flicker while converting, and value is also correct (not like using only style to alter display without changing real data).

提交回复
热议问题