How do I limit or restrict the user to only enter a maximum of five characters in the textbox?
Below is the input field as part of my form:
<input type="text" id="sessionNo" name="sessionNum" />
Is it using something like maxSize or something like that?
According to w3c, the default value for the MAXLENGTH attribute is an unlimited number. So if you don't specify the max a user could cut and paste the bible a couple of times and stick it in your form.
Even if you do specify the MAXLENGTH to a reasonable number make sure you double check the length of the submitted data on the server before processing (using something like php or asp) as it's quite easy to get around the basic MAXLENGTH restriction anyway
maxlength:
However, this may or may not be affected by your handler. You may need to use or add another handler function to test for length, as well.
Make it simpler
and use an alert to show that max chars have been used.
I alway do it like this:
Input:
Maxlength
The maximum number of characters that will be accepted as input. The maxlength attribute specifies the maximum number of characters allowed in the element.
Maxlength W3 schools
You can use
<input type = "text" maxlength="9">
or<input type = "number" maxlength="9">
for numbers or<input type = "email" maxlength="9">
for email validation will show up