Script for validating a form in javascript

posted by | Leave a comment

The expressions use a pre-defined class is returned which enables the form to be submitted.

This routine DOES NOT check that the date or time input values are valid, just that they match the required format (d/m/y and h:m). Once you're in control of the input format, it's a lot easier to check that the values are actually valid.

The code behind the form now is as follows: If you're not already familiar with regular expressions, then this might be getting a bit complicated.

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.

If you have such a form on your site, I'm sure that from time to time, you would have received the results of your form with some essential field (like the email address or the visitor's name, or even the feedback itself) omitted. One way around it is to validate the essential fields with a simple Java Script.

Note: You do not need to do the things mentioned in this article if you have created your feedback form using the Feedback Form Script Wizard.

Leave a Reply

Free online hot sex chat sighs