/    Sign up×
Community /Pin to ProfileBookmark

onclick/onsubmit validation problems

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>[/code]

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>
[/code]

Thanks!!!

Sheldon

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Sheldon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...