In this example, the date fields will only accept input that matches the pattern 'dd/mm/yyyy' (this could just as easily be changed to 'yyyy-mm-dd' or 'mm/dd/yyyy').The time field will allow input starting with 'hh:mm' following by an optional 'am' or 'pm'. The code behind the form is as follows: For each field in the form (first the dates, then the time field), a check is made as to whether the input is blank.
Once you have an HTML form up and running, you will often want to make sure that all the important fields are filled in.
For example, if you are going to send an email confirmation letter, the email address should be included in the form fields, and it should be an email address that works.
Most error checking programs check each field one at a time, and display one error at a time.
For example, when the date is checked, the return value, , is an array with elements 1 through 3 containing the day, month and year components of the input string.
For the time check, the array returned includes the hour (pos 1), minutes (pos 2) and, optionally, the am/pm string (pos 3).