You're not running your script through the PHP parser.
You're trying to make the Javascript parser execute PHP code.
What you want to do is...
HTML FORM
<script language="JavaScript" type="text/javascript">
function checkform (theform) {
if(!theform.yourvar.value) {
alert('Please enter a valid job number.');
return false;
}
else {
return true;
}
}
</script>
<form name="frm" method="post" action="checkform.php" onsubmit="return checkform(this);">
<input type="text" name="yourvar" />
<input type="submit" name="submit" value="Submit" />
</form>
PHP CODE
if(isset($_POST['yourvar']) && !$_POST['yourvar']) {
extract($_POST);
if (preg_match("/[A-a]{2,2}[0-9]{8,8}/", $yourvar)) {
echo "Please enter a valid job number";
}
}
Haven't checked it, but you should get the general idea.