Hi all, i just wrote this from an addaptation from and old script i have, my problem is the when i submit it doesnt run my validation script, just gots directly to the processing page.
I put the code in and out of the head with no difference.
[code=php]<script type=”text/javascript”>
String.prototype.isEmailAddress = function () {
return /^[^x00-x20()<>@,;:\”.[]x7f-xff]+(?:.[^x00-x20()<>@,;:\”.[]x7f-xff]+)*@[^x00-x20()<>@,;:\”.[]x7f-xff]+(?:.[^x00-x20()<>@,;:\”.[]x7f-xff]+)+$/.test(this)}
function validate(){
with (document.contact){
if (!email.value.isEmailAddress()) {
alert(“Please enter a Valid email address-“+email.value);
return false;
}
}else if (!name.value()) {
alert(“Please enter your name”);
return false;
}else if (!comment.value()) {
alert(“Please enter comment”);
return false;
}else {
alert(“Thanks your information has been sold and expect alot of junk email.”);
return false;
}
}
</script>
and the form
[code=php]
<p>
<i>
<p>
Send your story to Victoria
</p>
<p>
<form action=”index.php?show=finish” method=”post” name=”contact” onsubmit=”validate()”>
Name:<input type=”text” name=”name” size=”40″><br><br>
Email:<input type=”text” name=”email” size=”40″><br><br>
Comments:<textarea name=”comment” rows=”10″ cols=”40″></textarea>
</p>
<p>
<input type=”submit” value=”Send Email” onclick=”validate()”>
</form>
</p>
</i>
</p>
Thanks!!!
Sheldon