|
Javascript ignoring HTML maxlength
I am using the following code which inserts the number '1' into a HTML INPUT field when toggled.
The INPUT field has a maxlength set to 2, yet if I toggle the JavaScript insert function three times, it ignores the fact that that there is already two characters in the INPUT field and inserts a third character.
Does anyone know if its possible for JavaScript to stop this?
I don't think there is, and so have just thought up a solution now.
Within the subroutine that inserts the number '1', I am going to use an if string to detect if there are two characters in the INPUT field, and if there are, then disable the function that I insert the number '1' with.
Does anyone know how I can make JavaScript detect if there are two characters in an INPUT field?
Last edited by Phalanxer; 06-28-2012 at 11:30 AM..
|