Having some problems with getting this form to validate properly. I was able to get it to noticed if the field was empty. Now i need it to make sure the correct data is entered in ie.. numbers for serials and text for names.
Here is what i have now
[code]
function numchk($ticket){
if (!eregi(“^[a-z]{1,6}”, $ticket)){
return TRUE;
} else {
return False;
}
}
if (!numchk($tt)) {
echo ‘<font color=”red”>Ticket Number must contain numbers only!<br>’;
} else {
if (!empty($_POST[‘ticket’])){
$tt = $_POST[‘ticket’];
} else {
$tt = NULL;
echo ‘<font color=”red”>Enter a Ticket Number<br>’;
}
}
This works for the most part my only problem is if it has letters entered in it still completes the form but shows in red lettering “Ticket Number must contains numbers only!”. I thought it would stop the script and how that error. But it finishes the script and shows the error. What am i doing wrong?