I have an a text input with a maximum length:
<input type="text" name="name" maxlength="50">
This has been working fine on all the desktop browsers I've tried, but the maximum length does not seem to be enforced on mobile browsers.
Is there any way to get mobile browsers to enforce maxlength
? I am open to using JavaScript and/or jQuery in the solution.
Try this one:
jsFiddle here: http://jsfiddle.net/fttk2/1/
Universal jQuery way to enforce the stated
maxlength
of a form field. (I needed it for sessionStorage, localStorage, and param overrides.) Code optimized for readability.I'd suggest something a bit more simple. The aboves didn't work for me unless there was a space added for the field to pick up on it... or if I hit submit right after, it still passed the information.