Black Friday: the Laravel testing course is $149 instead of $249, through Dec 7. See the course →
logo

Make forms less frustrating for your users

Show them you care

Joel Clermont
Joel Clermont
2025-05-15

From our daily Laravel tips email. Get the next one in your inbox.

Earlier this year, I talked about why we validate maximum length on form request fields that will be saved to the database.

This is great for avoiding database exceptions or truncated data, but can we go a step further and make this even better?

A simple improvement is to also use the maxlength attribute on the HTML input element.

This will prevent the user from entering more characters than the maximum length, only to get a validation error when submitting.

Of course, on its own maxlength is not sufficient, but it's a nice additional UX improvement on top of the enforced server-side validation logic.

Here to help,

Joel

P.S. The Mastering Laravel Validation Rules book is a great resource for better leveraging the power of validation to write more reliable Laravel apps.

Want a tip like this in your inbox every weekday?

Each one takes less than 2 minutes to read. Join 4,000+ Laravel developers who already get them.

email
No spam. Only real-world advice.
Toss a coin in the jar if you found this helpful.