How can I combine these two functions so that they both work? Right now, I can only get one to validate and not the other.
SAMPLE OF THE JAVASCRIPT:
function validateForm() {
var x=document.forms["giftCert"]["gift_name"].value;
if (x==null || x=="") {
errMsg = "The recpient's name is required.";
$("div#emptyName").show();
$("div#emptyName").html(errMsg);
return false;
}
}
function validateForm() {
var x=document.forms["giftCert"]["gift_email"].value;
if (x==null || x=="") {
errMsg2 = "The recpient's email address is required.";
$("div#emptyEmail").show();
$("div#emptyEmail").html(errMsg2);
return false;
}
}
SHORT VERSION OF THE FORM HTML:
<form action="http://ww6.aitsafe.com/cf/voucher.cfm" method="post" name="giftCert" onsubmit="return validateForm()" />
*Name:<input type="text" name="gift_name">
<div id="emptyName" class="error"></div>
*Email: <input type="text" name="gift_email">
<div id="emptyEmail" class="error"></div>
<input class="button" type="submit" value="Add to Cart" />
</form>