I am trying to do a comparison of serial numbers like so 20140831-123 or 20140831-1234 so the form can accept our new serial numbers which contain 4 last numbers. So far I have tried an elseif statement and an or operator with no results what am I doing wrong? is there a way to change the reg expression itself to accept 3 or 4 digits at the end of the serial?
if($name == 'newserial1'){
$newserial1 = $_POST['newserial1'];
if($newserial1 != '') {
if(!preg_match('/^([0-9]{8}-)([0-9]{3})$/', $newserial1) ||
(!preg_match('/^([0-9]{8}-)([0-9]{4})$/', $newserial1))) {
$result['valid'] = false;
$result['reason'][$name] = 'Incorrect Serial Number.';
}
}
}