Hello people i have a textbox and i have its size 20 and its maxlength = 11.

it does show it in the textbox while writing, but it lets me insert 15 digit number to my database.

i type 12345123451 (it shows in my textbox)

then i type 9999(it doesn't show it in my textbox)

but when i alert textbox value.

it alerts 123451234519999

What can i do?

8 Years
Discussion Span
Last Post by Airshow


You have to be suspicious that something is going on behind the scenes.

As far as I am aware, all modern mainstream browsers honour maxlength and with maxlength=11 the user shouldn't be able to type in more than 11 characters.

However, I just ran a quick test in IE6 on a field with maxlength=11, and discovered that values greater than 11 characters length can be entered programmatically. So in IE6 at least, maxlength can be ovverridden.

This doesn't fully explain your symptoms but I would guess that there is an evnt handler (onfocus or onblur maybe) which is reading the field's value, storing it as a javascript variable (or in another, hidden field), then concatenating subsequent user input and somehow(?) displaying the full concatenated string when you think you are enquiring the field in question?!?!?!?!

I'm sure I could contrive to make a field behave this way but it doesn't seem like something that would happen by accident.

Very strange.

I suggest you migrate the code into a fresh (X)HTML page a piece at a time and see when it breaks.


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.