How to restrict number of characters in input field

HTML is such a beautiful language. Yes it has it built in to restrict the number of characters of any input field to whatever you want.

To restrict the number of alphabets or numbers inside an input field on your html form simply use maxlength attribute.

For example:

<input type="text" name="myinput" maxlength="10" value="" />

This will restrict the user to enter only upto 10 characters in the input field. It is cross browser compatible and works in firefox, internet explorer and chrome, all perfectly.

hire best wordpress php css developer
Need Help? Hire me now!
I can help you in anything related to webdevelopment, including: HTML, CSS, PHP & MySql, WordPress (plugins & themes development, others), regular expressions, server management, etc.

Leave a Reply

Your email address will not be published.