javascript-tutorialsmade

Basic JavaScript Form validation

Hello friends, If you are new to web development, you are at the right place to learn a lot of basic stuffs needed to be known. Today in this post I’m writing a very basic validation of a Web form using JavaScript.

This Basic JavaScript form validation covers the below,

1. How to validate a form before submit it.
2. How to get value of a input using it’s attribute id.
3. How to check if a input field is empty (only basic)

Here is the entire Basic JavaScript Validation script with HTML Form:

Read the comments in the above script to understand it.

ValidateForm() is the custom JavaScript function.

Onsubmit attribute helps to execute a JavaScript Function before submitting the form, if the JavaScript function returns false, then the form will not be submitted .

Here is the demo of the above script to test it online:

demo

Related Posts

Leave a Reply