HOW TO validate datetime fields?

Discuss everything related to DataValidator. All versions. Any questions related to the DataValidator developing or using should be posted to this forum.

Moderators: alexandrleonenko, goas

administrator
Site Admin
Site Admin
Posts: 6195
Joined: Jan 7th, '09, 23:18
Contact:

HOW TO validate datetime fields?

Postby administrator » Apr 9th, '13, 05:59

The solution to validate it as a string with your own regular expression.
(special thanks to Stacey Koster)

Below the example.
$regex = '/^\d{1,2}\/\d{1,2}\/\d{4}$/';
$validreadDate = new ValidatorTypeString("read_date", ValidatorTypeString::$subtypeAlphanumeric,'read date');
$validreadDate->SetRegExp($regex);
$validreadDate->SetSpacesAllowedFlag(1);
$validreadDate->SetPointingAllowedFlag(1);
$validreadDate->AddAdditionalElements("-","/",".");
$validator->AddType($validreadDate);

Return to “ApPHP DataValidator”