mpsn Posted April 7, 2012 Share Posted April 7, 2012 Hi, how do I evaluate form validation for a date to be in format: MM/DD/YYYY and to be between 2 years and 6 years of age, it's for a daycare center. Link to comment https://forums.phpfreaks.com/topic/260516-conditional-regular-expressions/ Share on other sites More sharing options...
AyKay47 Posted April 7, 2012 Share Posted April 7, 2012 can you post the relevant code please. Most likely you don't need a regex for this. Link to comment https://forums.phpfreaks.com/topic/260516-conditional-regular-expressions/#findComment-1335231 Share on other sites More sharing options...
mpsn Posted April 7, 2012 Author Share Posted April 7, 2012 I'm actually using WordPress form plugin and it takes in a regular expression only, so I can't tinker with the PHP files. I understand how to implement DD/MM/YYYY as: e.g. /\d{2}\/\d{2}\/\d{4}/ if all integers assuming Link to comment https://forums.phpfreaks.com/topic/260516-conditional-regular-expressions/#findComment-1335232 Share on other sites More sharing options...
AyKay47 Posted April 7, 2012 Share Posted April 7, 2012 ~\d{2}\/\d{2}\/(?:200[6-9]|2010)~ restrict the year to ensure that they were born between 2006-2019 (2-6 years ago). Note that this certainly isn't perfect, but it will get you started. Link to comment https://forums.phpfreaks.com/topic/260516-conditional-regular-expressions/#findComment-1335235 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.