dafyddgj dafyddgj - 9 months ago 56
Javascript Question

How to put max length on a field using JavaScript?

I've got a working function for empty fields already. Do I need another function to set a max length on these fields or can I edit my current function?
If so how would I fit the max length code in?

Answer Source

Don't use JavaScript to do HTML's job.

<input type="text" name="fname" required maxlength="10" />