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

后端 未结 5 700
不知归路
不知归路 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条回答
  •  闹比i
    闹比i (楼主)
    2021-02-07 03:01

    You may need to use combination of these.

    using the text-transform style only renders the type in upper-case, although the value may well be lower case.

    The javascript will only change current text to upper once the field changes or focus is lost

    you can use gazler's jquery or simply inline javascript

    e.g. onblur='javascript:this.value=this.value.toUpperCase();'

    This means that the text value will appear uppercase and actually be uppercased when the value changes / control loses focus.

    HTH Sam

提交回复
热议问题