Hi All,
I had come across a situation where i need to limit the character count into a text box. Suppose, your there is a requirement where the text box should take only 20 characters.
I had come across a situation where i need to limit the character count into a text box. Suppose, your there is a requirement where the text box should take only 20 characters.
In this situation preferably use the keypress method for
even to happen as follows
$('#IdOfTheTextBox’).keypress(function (e) {
if
(e.which < 0x20) {
//This snippet you have to use , otherwise it will not allow you perform action using backspace or delete button on FireFox
return;
}
if (this.value.length == "20")
{
e.preventDefault();
}
});
By doing above, it will not allow you to enter characters after 20the character.
Hope this will help .
cheers
Pradeepa Achar
Comments