I'm using PHP to validate form input before the form data's submitted to a MySQL database.
What would be the best way to validate a form input for the year only? I have a form input where users should input a date, in the form of a year only. Obviously I can check that the input's numeric and has only 4 characters, but what would be the best way to ensure that the number inputted is a sensible number for a date?
That would be sufficient for simple check;
$input = (int)$input;
if($input>1000 && $input<2100)
{
//valid
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With