Validating forms using vbscript
Form field validation is one of the most important functions in making successful web-based applications.It protects your database from errors, filters bad data, and forces the user to think twice before submitting data with typos.In both cases, the combo box would fire an on Blur event to indicate that it has lost focus.Like radio buttons or a combo box, a list box displays a list of items that the user can select from.For the sake of demonstration, we have taken five countries only. CSS Code of the Sample Registration Form The code above checks whether a sex is selected. If Male or Female is selected, it generates an alert saying that the form is successfully submitted and it reloads the form.Flowchart: Here is the entire Java Script used for validation of the form.
An alternative is to click the down pointing arrow.The later Java Script function created is called on the onsubmit event of the form.HTML Code of the Sample Registration Form is the external Java Script file which contains the Java Script ocde used to validate the form. Notice that for validation, the Java Script function containing the code to validate is called on the on Submit event of the form.This tutorial is designed to take the load off the servers for a while and get the beginning weblication programmer closer to the intermediate level and beyond. If the validation variable equals "True" then My Form_On Submit also equals "True." If the variable equals something else other than "True" Then My Form_On Submit will equal "False." If the Function equals "False" then the On Submit event will not execute and the user is prompted to fix their mistake.Otherwise, the On Submit event fires and the form data is posted to the page that will process the submitted form. Now granted, this is is a very simple example and in a real-world application you might have ten to twenty form fields to validate.