How do you automatically set text box to Uppercase?

后端 未结 12 746
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-29 23:50

I am using the following style attribute to set the user input to uppercase so that when the user starts typing in the text box for example railway, then it should

12条回答
  •  灰色年华
    2021-01-30 00:12

    This will both show the input in uppercase and send the input data through post in uppercase.

    HTML

    
    

    JavaScript

    var someInput = document.querySelector('#someInput');
    someInput.addEventListener('input', function () {
        someInput.value = someInput.value.toUpperCase();
    });
    

提交回复
热议问题