Validate your form using Javascript Validation
October 26, 2016 Comments 0 261 Views

Validate your form using Javascript Validation

Javascript validation of form reduce the overall process of correction required while submitting your data.

Javascript Validation help to get form data validated before it actually get send to the server.

In server side validation, submitted data is verified at server level and if there is some discrepancy in data format or missing field then form will get bounce and it will take more time. When you use javascript validation for verifing the data format or missing fields that will get executed at client side and get corrected without involving server and before reaching to server.

Here we are sharing some basics of javascript validation that are most commonly required for form validation.

The example given below is sample html form which contains few fields like name, Address,age, profession, email etc. See code below.

when user submit the form validation will get fired on submit event of javascript. see instance below

Now you need a function that will do the validation task. Below is the function and how you can write it.

In the example above, The validateForm function will is checking the mandatory checks of fields and also checking the email format. If there error found in submitted data alert will get fired to notify user that something went wrong with submitted data.

Previous PHP Quiz for Intermediate having good control
Next Easy steps on how to Install Joomla on your server

About author

You might also like

Sorry, no posts were found.