Member Avatar for feoperro

Hi,

How do you set a text input field to have a character limit?

Say for example, the user had to enter a postal code of 4 characters, how would you limit the text field to only allow 4 characters?

Thanks,
Ashton.

Hi Ashton

You can set a maxlength in the input field. Here is an example:

<input type="text" name="unique_name" value="" size="15" maxlength="4">

Where size is the visible input of the text box, and maxlength is the maximum caracters allowed.

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.