Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the data in ALL the textfields in a page to uppercase on click of a button

I have a page with some 13 textfields. I want to change the case of data in all the textfields to uppercase on click of a button. I can either user Jquery/javascript. I definitely don't want to use CSS-Text-transform property since it does not convert the case actually but just virtually.

Any suggestions as of how can I achieve this task using a single function ?

Thanks, Yeshwanth

like image 840
Yeshwanth Kota Avatar asked Dec 21 '22 17:12

Yeshwanth Kota


1 Answers

You can use val method:

$('#button').click(function(){
   $('input[type=text]').val(function(i, oldVal){
       return oldVal.toUpperCase()
   })
})
like image 103
undefined Avatar answered May 01 '23 03:05

undefined