How can I force input to uppercase in an ASP.NET textbox?
Why not use a combination of the CSS and backend? Use:
style='text-transform:uppercase'
on the TextBox, and in your codebehind use:
Textbox.Value.ToUpper();
You can also easily change your regex on the validator to use lowercase and uppercase letters. That's probably the easier solution than forcing uppercase on them.
Use a CSS style on the text box. Your CSS should be something like this:
.uppercase{ text-transform: uppercase;}<asp:TextBox ID="TextBox1" runat="server" Text="" CssClass="uppercase"></asp:TextBox>;
Okay, after testing, here is a better, cleaner solution.
$('#FirstName').bind('keyup', function () { // Get the current value of the contents within the text box var val = $('#FirstName').val().toUpperCase(); // Reset the current value to the Upper Case Value $('#FirstName').val(val);});