Cut & Paste Enforce max # of characters in form element
|
Description: Put a cap on the amount of characters certain form fields of your form accept, by using this useful script. Once the limit has been reached, typing within the field in question has no effect.
Example:
Directions
Step 1: Add the following script to the <HEAD> section of your page:
Step 2: Then, add the below sample form to your <BODY>:
As illustrated inside the form, to enforce characters inside a form element, apply the code:
onkeypress="return enforcechar(this, 10)"
inside it, changing 10 to the maximum # of characters the element(s) is to accept. Applicable elements are TEXTAREA or <INPUT>.
JavaScript Tools:
Site Info
