Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do make the text in the TEXTBOX to Capital letter when the user starts typing text in jquery

Tags:

jquery

when the user starts typing the text in to the text box we need to make those letters to capital letters

like image 977
Someone Avatar asked Dec 09 '22 13:12

Someone


2 Answers

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!

like image 53
chigley Avatar answered May 23 '23 13:05

chigley


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.

like image 20
Ender Avatar answered May 23 '23 14:05

Ender