help please

  • aclearweb
  • Born
  • Born
  • aclearweb
  • Posts: 1

Post 3+ Months Ago

I'm a bit new to all this so am looking for some help please.

I am trying to validate a form:

<form method="post" name="form" action="thanks.php" style="height: 76px" onsubmit="javascript:return Validate(this)">

What happens is, the IsEmpty part works fine on all three fields but it does not continue on to validate the email address (isValidEmail)- it just posts without checking it.


<SCRIPT LANGUAGE="JavaScript">
function Validate(){

if(IsEmpty(form.fullName)) {
alert("Please enter your name");
form.fullName.focus();
return false;
}
if(IsEmpty(form.email_add)) {
alert("Please enter your email address");
form.email_add.focus();
return false;
}

if(IsEmpty(form.phoneNum)) {
alert("Please enter a contact telephone number");
form.phoneNum.focus();
return false;
}
if(isValidEmail(form.email_add.value)){
alert("Your email address is not valid, please re-enter");
form.email.focus();
return false;
}
return true;
}

function isValidEmail(str) {
return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

}
function IsEmpty(aTextField) {
if ((aTextField.value.length==0) ||
(aTextField.value==null)) {
return true;
}
else { return false; }
}
</SCRIPT>


Jan

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 124 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.