Here an example my form http://jsfiddle.net/GT7fY/
How to convert all text to uppercase while user writing on the field?
Use keyup() method to trigger the keyup event when user releases the key from keyboard. Use toLocaleUpperCase() method to transform the input to uppercase and again set it to the input element.
The toUpperCase() method converts a string to uppercase letters. The toUpperCase() method does not change the original string.
As an aid to form validation we can use HTML5 input patterns to flag when an input is not valid. In the JavaScript examples, the pattern to enforce only uppercase (assuming a single word - no spaces or punctuation) is: <input ... pattern="[A-Z]*" ...>
The toLocaleUpperCase() method converts a string to uppercase letters, using current locale. The locale is based on the language settings of the browser. The toLocaleUpperCase() method does not change the original string.
You could use keyup()
and toUpperCase()
$('input').keyup(function(){
this.value = this.value.toUpperCase();
});
fiddle here http://jsfiddle.net/GT7fY/2/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With