/    Sign up×
Community /Pin to ProfileBookmark

Confirm you email address

I’m trying to confirm that the email address and confirm email address are the same. I have enter this code but it always come back with the error message even when the email and confirm email address are the same.

<script language=”javascript” type=”text/javascript”>
function Compare(Email1, Email2)
{if (FrontPage_Form1.Email1.value == FrontPage_Form1.Email2.value)
{return true;}
else
{ alert(“Your Email Address and Confirm Email Address must be the same.”);

return false;}

}
</script>
</head>
in the body i have the onsubmit:

<FORM onsubmit =”Compare (Email1, Email2)” language=”JavaScript” METHOD=”POST” ACTION=”–WEBBOT-SELF–” name=”FrontPage_Form1″>

It should compare the two to make sure they are the same and move on to creating the email and confirmation page. If I don’t check the two email address just send the email and create the confirmaiton page everything works. Well I mean they can enter two different email but the email goes out and the confirmation page is created.

PLEASE Help. This is my first page.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@GollumOct 27.2003 — by the looks of things,

Email1 and Email2 are text boxes inside your form.

The problems I can see are...

where you say onsubmit="Compare(Email1,Email2);", The terms Email1 and Email2 don't mean anything by themselves. You might try "Compare(this.Email1,this.Email2)" or "Compare(FrontPage_Form1.Email1,FrontPage_Form1.Email2)"

in your function Compare(Email1,Email2), you don't actually use the two arguments at all (even though you have FrontPage_Form1.Email1.value, etc) so the function is probably not acting the way you think it is (although it will probably work due to the coincidental fact that the element names are the same. You could change the first line to
<i>
</i>if (Email1.value == Email2.value)
Copy linkTweet thisAlerts:
@pj_amp_bauthorOct 27.2003 — Ok I've changed the onsubmit to include the

onsubmit ="Compare(FrontPage_Form1.Email1, FrontPage_Form1.Email2)"

Are you saying next that:

function Compare(FrontPage_Form1.Email1, FrontPage_Form1.Email2)

should be more like

function Compare(this).

and the code below the function:

{if (Email1.value == Email2.value)

{return true;}

else

{ alert("Your Email Address and Confirm Email Address must be the same.");


return false;}

}

</script>

</head>

This still comes back with an error when the two emails are the same. Sorry I know it's hard to work with people new to this. But thank you I've worked all week end.
Copy linkTweet thisAlerts:
@CharlesOct 27.2003 — [font=monospace]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta name="Content-Script-Type" content="text/javascript">

<title>Example</title>

<style type="text/css">

<!--

label {display:block; margin:1em 0em}

input {display:block}

-->

</style>

<script type="text/javascript">

<!--

String.prototype.isEmailAddress = function () {return this.match(/^[^x00-x20()<>@,;:".[]x7f-xff]+(?:.[^x00-x20()<>@,;:".[]x7f-xff]+)*@[^x00-x20()<>@,;:".[]x7f-xff]+(?:.[^x00-x20()<>@,;:".[]x7f-xff]+)+$/)}

// -->

function verify (form) {if (form.address.value != form.confirm.value) {alert('The two addresses do not match.'); return false}}

</script>

<form action="" onsubmit="return verify(this)">

<div>

<label>Email Address<input name="address" type="text" onchange="if (!this.value.isEmailAddress()) {alert('That would not appear to be a valid email address.'); this.value=''; this.focus()}"></label>

<label>Confirm Address<input name="confirm" type="text" onchange="if (!this.value.isEmailAddress()) {alert('That would not appear to be a valid email address.'); this.value=''; this.focus()}"></label>

<button type="submit">Submit</button>

</div>

</form>[/font]
Copy linkTweet thisAlerts:
@JonathanOct 28.2003 — [i]Originally posted by Charles [/i]

[B][font=monospace]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta name="Content-Script-Type" content="text/javascript">

<title>Example</title>



<style type="text/css">

<!--

label {display:block; margin:1em 0em}

input {display:block}

-->

</style>



<script type="text/javascript">

<!--

String.prototype.isEmailAddress = function () {return this.match(/^[^x00-x20()<>@,;:".[]x7f-xff]+(?:.[^x00-x20()<>@,;:".[]x7f-xff]+)*@[^x00-x20()<>@,;:".[]x7f-xff]+(?:.[^x00-x20()<>@,;:".[]x7f-xff]+)+$/)}

// -->



function verify (form) {if (form.address.value != form.confirm.value) {alert('The two addresses do not match.'); return false}}

</script>



<form action="" onsubmit="return verify(this)">

<div>

<label>Email Address<input name="address" type="text" onchange="if (!this.value.isEmailAddress()) {alert('That would not appear to be a valid email address.'); this.value=''; this.focus()}"></label>

<label>Confirm Address<input name="confirm" type="text" onchange="if (!this.value.isEmailAddress()) {alert('That would not appear to be a valid email address.'); this.value=''; this.focus()}"></label>

<button type="submit">Submit</button>

</div>

</form>[/font] [/B]
[/QUOTE]


you are truely crazy, where did you come up with that?!?! and can you explain it to me please ? really... I don't know the first thing about that script, and I love javascript.
×

Success!

Help @pj_amp_b 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.17,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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