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.
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.
With upperCaseF() function on every key press down, the value of the input is going to turn into its uppercase form.
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.
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(),
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