I\'m trying to validate a date input by the use of regex.
if(!preg_match(\"/^[0-9]{4}\\/[0-9]{2}\\/[0-9]{2}$/\", $_POST[\'variant\'][\'sales_start\'])) {
You're separating the date with dashes and the regex is looking for slashes?
Try
if ( !preg_match( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $_POST['variant']['sales_start'] ) ) { echo "invalid"; }