Click to See Complete Forum and Search --> : Validating "confirm E-Mail" text input


789123
02-22-2005, 06:11 PM
I have created an .asp form input script to write to an access database.

One of the fields is E-Mail__________
The next is Confirm E-mail _________

Any ideas on how to make sure that the Confirm E-Mail matches the E-Mail field input?

Thanks for you time.

JPnyc
02-22-2005, 06:33 PM
Do that clientside with Javascript. No sense making a trip to and from the server for that.
<script type="text/javascript">
<!--
function emailCheck() {
var eOne=document.forms[0].email1.value;
var eTwo=document.forms[0].email2.value;

if(eOne != eTwo) {
alert('The 2 emails must be identical');
return false;
}
else {
return true;
}}
//-->
</script>
Then inside the form tag, onsubmit="return emailCheck();">

buntine
02-22-2005, 07:08 PM
Do it from the server aswell as JavaScript can be disabled.

Dim strEmail1, strEmail2
strEmail1 = LCase(Request.Form("email1"))
strEmail2 = LCase(Request.Form("email2"))

If strEmail1 <> strEmail2 Then
Response.Write("emails do not match")
Response.End
End if

Regards.

789123
02-22-2005, 09:00 PM
I hate to be ignorant JP, but precisely where should this script go in my .asp document?


THIS
onsubmit="return emailCheck">


GOES WHERE IN HERE

<form METHOD="POST" action="--WEBBOT-SELF--" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" name="FrontPage_Form1">

Thanks

buntine
02-22-2005, 09:04 PM
It seems you already have a generated validation function in your page. Anyway, try this:

<form METHOD="POST" action="--WEBBOT-SELF--" onsubmit="return FrontPage_Form1_Validator(this); return emailCheck();" language="JavaScript" name="FrontPage_Form1">

The script JPncy gave you should be placed within the <head> and </head> tags.

Regards.

789123
02-22-2005, 09:18 PM
I hate to use all this code, but here goes. BTW this does not work

1. The Java:
%>
<html>
<head>
<title>JavaScript Menu</title>
<style>
a, A:link, a:visited, a:active
{color: #0000aa; text-decoration: none; font-family: Tahoma, Verdana; font-size: 11px;}
A:hover
{color: #ff0000; text-decoration: none; font-family: Tahoma, Verdana; font-size: 11px;}
p, tr, td, ul, li
{color: #000000; font-family: Tahoma, Verdana; font-size: 11px;}
sup
{color: #000000; font-family: Tahoma, Verdana; font-size: 9px;}
.header1, h1
{color: #ffffff; background: #4682B4; font-weight: bold; font-family: Tahoma, Verdana; font-size: 13px; margin: 0px; padding: 2px;}
.header2, h2
{color: #000000; background: #DBEAF5; font-weight: bold; font-family: Tahoma, Verdana; font-size: 12px;}
.intd
{color: #000000; font-family: Tahoma, Verdana; font-size: 11px; padding-left: 15px; padding-right: 15px;}
form
{ margin: 2px;}
<script type="text/javascript">
<!--
function emailCheck() {
var eOne=document.forms[0].email1.value;
var eTwo=document.forms[0].email2.value;

if(eOne != eTwo) {
alert('The 2 emails must be identical');
return false;
}
else {
return true;
}}
//-->
</script>


2. The "on Submit":
<form METHOD="POST" action="--WEBBOT-SELF--" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" name="FrontPage_Form1">



Thanks

russell
02-22-2005, 10:25 PM
do this

<script><!--
function validateForm(f) {
if emailCheck()
return FrontPage_Form1_Validator(f);
return false;
}
// -->
</script>
<form METHOD="POST" action="--WEBBOT-SELF--"
onsubmit="return validateForm(this)"
name="FrontPage_Form1">
we haven't seen the code in the FrontPage_Form1_Validator() function, but assuming it returns true or false, then this'll do it.

what we are doing is calling first the email validation method, then, if it returns true, calling the other function. both mist return true for the form to submit

789123
02-23-2005, 05:51 AM
Thanks, I'll give it a try tonight.

Hopefully we'll have success.

buntine
02-23-2005, 06:26 AM
Just for clarification, you should always refer to JavaScript as JavaScript and not Java. The two are completely different. Its not relevant, but may be helpful.