I've got a premade Regular expression function that seems to not be picking up the reg expression correctly. The previous programmer couldn't get it working and neither could I.
function RegExp($name, $re, $error) { // Client $this->AddJS(" re = $re; if(!re.test(form.$name.value)) { alert('$error'); form.$name.focus(); return false; } "); // Server if(preg_match($re, $_REQUEST["$name"]) == 0) { $this->errors[] = $error; return false; } else { return true; } }
RegExp('VISIT','/([0-9]{2})\/([0-9]{2})\/([0-9]{4})/', 'Please, enter correct requested ship date.');
10/22/2010 4:15:30 PM
function RegExp($testValue, $re){ if(preg_match($re, $testValue) == 0) { return 'fail'; } else { return 'pass'; } } echo '---'.RegExp('10/23/2010','/([0-9]{2})\/([0-9]{2})\/([0-9]{4})/').'<br>';echo '---'.RegExp('10/230/2012','/([0-9]{2})\/([0-9]{2})\/([0-9]{4})/').'<br>';
10/23/2010 7:48:39 AM
the client side will not pop up with the error. Will try yours monday and see how it goes.Server side php works good. [Edited on October 24, 2010 at 11:02 AM. Reason : ss]
10/24/2010 11:01:17 AM