We have witnessed the wonders of JavaScript and its ability to ensure that our forms are properly filled before submission. But it gets so laborious to type and modify and update form validation scripts for every for in every application. Take heart! Upon reading and applying the methods in this article, you will never again have to worry about client-side validation! Hazzah!
So you’ve cleverly deuced that the JavaScript functions will be contained in one big container file called ‘forms.js’. Whenever we have a form that needs validating, all that need be done is a simple inclusion of this script file, and the attaching of ‘_required’ to the end of any… you guessed it, required fields! Oh, and one more thing.
We need to tell the client browser that when the user is done filling out the form, please verify it before sending to the server. This is accomplished by the onsubmit handler.
But what was that whole mess with the age field? We’ll deal with that a little bit later, for now let’s delve into the workings of the actual checkForm function.