Reputation: 10575
when the user starts typing the text in to the text box we need to make those letters to capital letters
Upvotes: 4
Views: 8059
Reputation: 6542
Just add text-transform: uppercase to your styling, and then on the server side you can convert it to uppercase.
input {
text-transform: uppercase;
}
Upvotes: 3
Reputation: 15221
EDIT: See chigley's answer instead.
$(function() {
$('#myTextBox').keyup(function() {
$(this).val($(this).val().toUpperCase());
});
});
Demo: http://jsfiddle.net/SMrMQ/
Alternately, style with CSS and do actual conversion on your back-end.
Upvotes: 2
Reputation: 2592
Instead of a jQuery solution, I'd be tempted to use CSS to make the text inside the input to appear to be capitals (text-transform: uppercase
), regardless of whether or not they were inputted as lower or upper case. Then when you process your data, convert the data to upper case. For example in PHP, you'd use strtoupper()
- there are equivalent functions in most other languages I imagine you might be processing the form with!
Upvotes: 8
Reputation:
$(function() {
$('input[type=text]').bind('keyup', function() {
var val = $(this).val().toUpperCase()
$(this).val(val);
});
});
Test it here :http://jsbin.com/opobu3
Upvotes: 2