Validating data in javascript Live chat discreet

by  |  10-May-2016 20:48

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.

If not, the input is compared to the regular expression.

The zip file contains the javascript file, examples.

The function has been improved now so that the day, month and year values are checked to ensure that they're in the right ball-bark (ie. Also the year must be between 1902 and the current year.

The year limitation would be used if you were asking for a date of birth or date of some recent event.

In other words, in order to validate a field, you just associate a set of validation descriptors for each input field in the form. For such cases, a function is included which clears all validations in the validator object. Note that this validation if for fields like Textbox and multi-line text box.

For ‘selections’ like drop down and radio group, use an appropriate validation like ‘dontselect’ or ‘selone_radio’.

For the time check, the array returned includes the hour (pos 1), minutes (pos 2) and, optionally, the am/pm string (pos 3).

Community Discussion