displaying too many error messages at one time to fields I added
I am having a terrible time adding extra form fields to the contact form and applying the validations to my new fields to display error messages correctly. Here is a link to the uploaded contact form: contact.php
For client side spry validations, all the new fields I added display multiple error messages. How do I make it only display the pertinent error message onblur here instead of mulitple error messages on each of the fields that I added?
For server side validations only the phone number text field displays error messages wrong. There are two possible error messages on the phone number text field; one that says "A value is required." if nothing was entered, and a second one that says "Invalid format, please re-enter your phone number." The problem is that if nothing is entered, both error messages appear when the form is submitted; the second message about invalid format should not appear in this case. How do I make it only display the first error message and not the invalid format message, if they have simply neglected to enter anything at all here?
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$WAFV_Redirect = "";
$_SESSION['WAVT_contact_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact_Name"]))?$_POST["Contact_Name"]:"") . "",true,1);
$WAFV_Errors .= WAValidateEM(((isset($_POST["Email_address"]))?$_POST["Email_address"]:"") . "",true,2);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Comments"]))?$_POST["Comments"]:"") . "",true,3);
$WAFV_Errors .= WAValidateLE(((isset($_POST["Security_code"]))?strtolower($_POST["Security_code"]):"") . "",((isset($_SESSION["captcha_1"]))?strtolower($_SESSION["captcha_1"]):"") . "",true,4);
$WAFV_Errors .= WAValidateLE(((isset($_POST["Security_question"]))?strtolower($_POST["Security_question"]):"") . "",((isset($_SESSION["random_answer"]))?strtolower($_SESSION["random_answer"]):"") . "",true,5);
$WAFV_Errors .= WAValidateRX(((isset($_POST["addblock"]))?$_POST["addblock"]:"") . "","/^$/i",false,6);
$WAFV_Errors .= WAValidateRX(((isset($_POST["seconddblock"]))?$_POST["seconddblock"]:"") . "","/^$/i",false,7);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["company_name"]))?$_POST["company_name"]:"") . "",false,8);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["address"]))?$_POST["address"]:"") . "",false,9);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["city"]))?$_POST["city"]:"") . "",false,10);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["zip"]))?$_POST["zip"]:"") . "",false,11);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["phone"]))?$_POST["phone"]:"") . "",true,12);
$WAFV_Errors .= WAValidatePN(((isset($_POST["phone"]))?$_POST["phone"]:"") . "",true,false,true,13);
if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"contact");
}
}
?>