Hello. I have a form, but there are four fields that don't validate correctly. In the Position, Company, and Address fields, I want the visitor to be able to enter letters, numbers, spaces, and hyphens. In the Telephone field, I want them to only be able to enter numbers and spaces. Here is the code I have so far:
if (ereg("[^[:alpha:]]", $position) || strlen($position) == 0) {$errormsg .= "<font color=\"#CC0000\" face=\"Verdana\"><b>You must enter your Position.</b></font><br>";}
if (ereg("[^[:alnum:]]", $company) || strlen($company) == 0) {$errormsg .= "<font color=\"#CC0000\" face=\"Verdana\"><b>You must enter your Company.</b></font><br>";}
if (ereg("[^[:alnum:]]", $address) || strlen($company) == 0) {$errormsg .= "<font color=\"#CC0000\" face=\"Verdana\"><b>You must enter your Address.</b></font><br>";}
if (ereg("[^[:digit:]]", $telephone) || strlen($telephone) == 0) {$errormsg .= "<font color=\"#CC0000\" face=\"Verdana\"><b>You must enter a valid Telephone Number.</b></font><br>";}
Any help with this will be appreciated. Thanks.