[ACCEPTED]-Convert lowercase letter to upper case in javascript-javascript
Accepted answer
<script type="text/javascript">
function ChangeCase(elem)
{
elem.value = elem.value.toUpperCase();
}
</script>
<input onblur="ChangeCase(this);" type="text" id="txt1" />
separate javascript from your HTML
window.onload = function(){
var textBx = document.getElementById ( "txt1" );
textBx.onblur = function() {
this.value = this.value.toUpperCase();
};
};
<asp:TextBox ID="txt1" runat="server"></asp:TextBox>
If the 2 textbox is inside a naming container then 1 use something like this
var textBx = document.getElementById ("<%= txt1.ClientID %>");
textBx.onblur = function() {
this.value = this.value.toUpperCase();
};)
Have you tried .toUpperCase()
?
Links:
0
If you don't want to make an explicit JavaScript 2 function, here you can do it in just one 1 line:
Convert to lower and upper case respectively:
<asp:TextBox ID="txt1" onblur='this.value = this.value.toLowerCase();'></asp:TextBox>
<asp:TextBox ID="txt1" onblur='this.value = this.value.toUpperCase();'></asp:TextBox>
You can simply use CSS and do text-transform:uppercase
and on submit 2 you run toUppercase(). Or you just submit as mixed and 1 you capitalize letters on server side :)
I would say the easiest way is..
<input id="yourid" style="**text-transform: uppercase**" type="text" />
0
Have you tried this?
var myString = "this is a String";
alert(myString.toUpperCase()); // "THIS IS A STRING"
alert(myString.toLowerCase()); // "this is a string"
Thanks... Hope you like 1 it.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.