Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Input to Upper Case

JS:

<script type="text/css"> $(function() {     $('#upper').keyup(function() {         this.value = this.value.toUpperCase();     }); }); </script> 

HTML

<div id="search">         <input type="radio" name="table" class="table" value="professor" tabindex="1" /> Professor         <input type="radio" name="table" class="table" value="department" tabindex="2" /> Department         <input type="radio" name="table" id="upper" class="table" value="course" tabindex="3" /> Course         <input type="text" name="search" class="keywords" value="Select an option..." onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?':this.value;" tabindex="4"  />         <div id="content"> </div>     </div> 

Why is this still not working?? Just trying to call div ".keywords" from JS.

like image 329
Jshee Avatar asked Apr 22 '11 15:04

Jshee


People also ask

How do you uppercase an input?

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.

How do you capitalize input in Javascript?

The toUpperCase() method converts a string to uppercase letters. The toUpperCase() method does not change the original string.

How do you force uppercase in HTML?

With upperCaseF() function on every key press down, the value of the input is going to turn into its uppercase form.

How do you change uppercase to input in python?

upper() In Python, upper() is a built-in method used for string handling. The upper() methods returns the uppercased string from the given string. It converts all lowercase characters to uppercase.


1 Answers

I think the most elegant way is without any javascript but with css. You can use text-transform: uppercase (this is inline just for the idea):

<input id="yourid" style="text-transform: uppercase" type="text" /> 

Edit:

So, in your case, if you want keywords to be uppercase change: keywords: $(".keywords").val(), to $(".keywords").val().toUpperCase(),

like image 157
Tim Avatar answered Oct 29 '22 01:10

Tim