Php regex date validation -


i'm trying validate date input use of regex.

if(!preg_match("/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}$/", $_post['variant']['sales_start'])) {    echo "invalid"; } 

the string i'm trying input 2011-02-03, it's failing, , can't seem figure out why.

can please tell me i'm doing wrong?

thanks in advance

you're separating date dashes , regex looking slashes?

try

if ( !preg_match( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $_post['variant']['sales_start'] ) ) {      echo "invalid"; } 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -