Validating forms in html
Each field in the form can have zero one or more validations. More info & downloads where Do My Validation One() and Do My Validation Two() are custom functions for validation.For example, you can have an input field that should not be empty, should be less than 25 chars and should be alpha-numeric. In some dynamically programmed pages, it may be required to change the validations in the form at run time.The idea is to create a set of “validation descriptors” associated with each element in a form.The “validation descriptor” is nothing but a string specifying the type of validation to be performed.
In tandem with the new input types and attributes provided by HTML5, CSS3 gives us some new pseudo-classes we can use to provide visual clues to the user as to which form fields are required, which are optional, and which contain validation errors.To start using the new input types and attributes, you don't really need to do anything other than start using the new input types and attributes.Strictly speaking, you should make sure you're using the HTML5 DOCTYPE, otherwise you'll run into HTML validation errors.This keeps our HTML semantic, with the labels helping to give meaning to the input controls.
It also means that if you click the label, the associated input tag receives the focus.We'll want the 'Name' field to be submitted in the format 'Firstname Lastname', and to only contain letters and a space (NB in real world scenarios, you might need to take account of other locales – this example has been kept simple deliberately).