Sometimes we need to make the text field force uppercase so that the user can add only the uppercase letters in it. Using jQuery you can automatically convert text field value while typing. Not only the jQuery, here we will show you the three different way to transform text field data to uppercase while typing.
jQuery keyup() method triggers the keyup event and the toUpperCase() function converts text to uppercase.
$(document).ready(function(){ $('#id').keyup(function(){ $(this).val($(this).val().toUpperCase()); }); });
The uppercase()
method converts text to uppercase using JavaScript. Call the uppercase() function by onkeyup
event of the text field.
function uppercase(obj){ obj.value = obj.value.toUpperCase(); }
Use text-transform
property in CSS to transform a text field to uppercase.
#id{text-transform: uppercase;}
I think the CSS method is not good, as it changes only the appearence of the field; the actual value is not changed and it is sent to the server in non-upper case.
Thanks! It is working perfectly.
Good job
NIce Job working fine…….
good job