Validating date in php

by  |  12-Sep-2019 21:00

If not, the input is compared to the regular expression.The expressions use a pre-defined class is returned which enables the form to be submitted.

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).

These functions can even be included from an external javascript file so that the browser can cache them, and so the programmer isn't always copying and pasting.

In this case, we've created a stand-alone functions which will validate a date field: In each case the value passed to the function is the form field rather than the field value.

Instead we're going to make use of Form Validation using Ajax to do some real-time checking using a server-side PHP script to get a definitive answer.

Community Discussion