Tutorial

Use this tag to display an article in the 'Learn more' view.

Limit the maximum length of submitted data

Here's one way of many of making sure that user submitted data does not exceed a maximum allowed length (set by the form author) in a form control.

Say there's the scenario that requires you to ensure that when someone comments on your blog post, they do not enter more than 25 characters (you're not looking for detailed feedback on your post!).

The approach demonstrated here is to disable the button the user needs to press to submit their comment unless the text they enter is less than or equal to 25 characters. If they do enter more than that, we disable the button and inform them that they need to shorten their comment. It's also nice to let them know how many characters they have left to enter too.

Syndicate content