I have a code that will convert lower case letters to uppercase but it works only with IE and not in Crome or Firefox.
function ChangeToUpper()
{
<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 textbox is inside a naming container then use something like this
var textBx = document.getElementById ("<%= txt1.ClientID %>");
textBx.onblur = function() {
this.value = this.value.toUpperCase();
};)
You can simply use CSS and do text-transform:uppercase
and on submit you run toUppercase(). Or you just submit as mixed and you capitalize letters on server side :)
Have you tried .toUpperCase()
?
Links:
If you don't want to make an explicit JavaScript function, here you can do it in just one 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>
I would say the easiest way is..
<input id="yourid" style="**text-transform: uppercase**" type="text" />
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 it.