schoolteacher schoolteacher - 3 months ago 9
HTML Question

Why this validate length not working?

The minimum length of firstname:

2


if (firstname.length < 2 && firstname.length > 20) return false;


When users enter the firstname input it still count in 6.

Answer

Use or condition instead of and in if block

if (username.length < 6 || username.length > 20) return false;
if (firstname.length < 2 || firstname.length > 20) return false;

Mark as answer if it answer your question.