Javascript Form Validation
JavascriptForm Validation with built-in HTML functions
Though this is not Javascript, this is a type of form validation, by using the HTML built-in form check functions:
This method is not widely used anymore, because it has a few security risks - for instance, you can just go to the developer tab and delete the attributes that check the form validation, which is a benefit for hackers. The validation messages also look outdated by design side.
Form with Javascript checks
By doing validation with Javascript, you have much more control over errors and successes:
That way you have a custom way to handle forms, which is always good when you are looking for a specific site theme.
Advanced version with live feedback and reusability
Here are set various error elements to handle specific errors and also username, email and password validations:
This method is ideal for large-scaled apps and people often use this. Javascript is overall a way to handle form validation as a fallback, in case the server side validation has problems. Though, relying only on Javascript to handle forms is not a good thing to do, because anyone can access Javascript in developer tools and start doing malicious things to your website - just wanted to let you know.