| View previous topic :: View next topic |
| Author |
Message |
mcbc
Joined: 21 May 2008 Posts: 12
|
Posted: Wed May 21, 2008 4:36 pm Post subject: Not validating emails. |
|
|
Hi my script will not run the code to check email, here is the code, and any help will be great.
<style type="text/css">
<!--
.style5 {font-family: Verdana, Arial, Helvetica, sans-serif}
.floatingImage {
position: absolute;
left: 597px;
top: 109px;
width: 415px;
height: 76px;
}
a:link {
color: #009900;
}
-->
</style>
<style type="text/css">
<!--
.style11{
font-size:80%;
position:super;
vertical-align:super;
}
-->
</style>
<style type="text/css">
<!--
.style12{
font-size:75%;
position:super;
vertical-align:top;
}
-->
</style>
<SCRIPT language="JavaScript">
function calculateOrder()
{
var quantity, totalOrder;
quantity = parseFloat(document.frmOrder.BookNumber.value);
totalOrder = quantity * 12.95;
document.frmOrder.Price.value = totalOrder.toFixed(2);
}
</SCRIPT>
<script type="text/javascript">
function CompareEmail(Email, ConfirmEmail)
var Email == document.frmOrder.Email.value;
var ConfirmEmail == document.frmOrder.Confirm Email.value;
{
if (Email == Confirm Email){
return true;
} else if (Email == '' || Confirm Email == '')
{
alert('Please fill out both email fields.');
return false;
}else{
(Email != Confirm Email)
alert('Email values are not equal to one another!');
return false;}
}
</script>
<link href="forms.css" rel="stylesheet" type="text/css" />
</head>
<body class="oneColFixCtrHdr">
<div id="container">
<div id="header">
<!-- end #header --></div>
<div id="mainNav">
<ul>
</ul>
</div>
<div id="mainContent">
<div id="rightcolumn">
</div>
<div class="style1" id="leftcolumn" style="position:absolute; width:420px; top:185px;padding-right:5px;">
<h1 class="titles">Manual $12.95 + shipping and handling</h1>
Printed using 100% recycled paper: 68 pages, 8.5" x 11", coil binding, black and white interior ink.<br />
Maufactured using the ECOLITH<span class="style11">®</span> Process.<br />
<br />
<span class="titles"><strong>Description</strong></span><br />
<br />
Learn the basics of how the real estate profession will participate in the new arena of "green." Topics are discussed as an introduction as the first level in the highly acclaimed "Real Estate Environmental and Energy Education Certification Series." This series will be written and produced over the next 4 years, with collaboration by "green building" experts knowledgeable in all phases of the "green" built structure.
<p> </p>
<FORM METHOD="POST" ACTION="mailto:?&subject=Green Manual Order!! " ENCTYPE="text/plain" method="post" name="frmOrder" onsubmit="return CompareEmail(Email, ConfirmEmail);">
<legend></legend>
<label for="required1"><span>*</span>Email</label>
<input type="text" name="Email" id="Email*" /><br />
<label for="required2"><span>*Confirm Email</span></label>
<input type="text" name="Confirm Email" id="ConfirmEmail*" /><br />
<label for="BookOrder">Number of Books</label>
<input type="text" name="BookNumber" size="5" maxlength="5" id="Number of Books" onchange="calculate()" value="0" />
<input type="button" value="Calculate" name="btnCalculate" onClick="calculateOrder()"><br />
<label for="Price">Price$</label>
<input type="text" name="Price" size="10" maxlength="15" id="Price of Books" /> (+ Shipping and Handling and Taxes)<br />
<br/>
<input type="submit" value="Submit" onclick="return CompareEmail(Email, ConfirmEmail);"><br />
<label for="Confirm">We will call you to confirm your order, shipping,
and payment details.</label><br /><br />
</fieldset>
</form>
</div>
</div>
</body>
</html> |
|
| Back to top |
|
 |
|
|
rangana 500+ Club

Joined: 27 Feb 2008 Posts: 563 Location: Cebu City Philippines
|
Posted: Thu May 22, 2008 2:34 am Post subject: Re: Not validating emails. |
|
|
When assigning a variable, it should only be = and not ==
| Quote: |
| Code: |
var Email == document.frmOrder.Email.value;
var ConfirmEmail == document.frmOrder.Confirm Email.value;
|
|
Also, JS is case senstive Confirm Email is different from ConfirmEmail.
Your problem is that you don't have a ConfirmEmail texbox, but a Confirm Email. Don't use both ConfirmEmail as name and id (though you suffix the latter with *) because IE regards the two as synonymous.
This part in your JS is correct, but you should also note that when the user has no input on both Email and Confirm Email it still validates:
| Code: |
if (Email == ConfirmEmail)
|
language is a deprecated attribute used in <script> tag. The modern way is to use type attriibute.
Validation should be on submit (only) and not with the onclick of the submit button.
I've got a lot of ammendments from your markups and the script. See if this helps:
| Code: |
<html>
<head>
<style type="text/css">
<!--
.style5 {font-family: Verdana, Arial, Helvetica, sans-serif}
.floatingImage {
position: absolute;
left: 597px;
top: 109px;
width: 415px;
height: 76px;
}
a:link {
color: #009900;
}
-->
</style>
<style type="text/css">
<!--
.style11{
font-size:80%;
position:super;
vertical-align:super;
}
-->
</style>
<style type="text/css">
<!--
.style12{
font-size:75%;
position:super;
vertical-align:top;
}
-->
</style>
<script type="text/javascript">
function calculateOrder()
{
var quantity, totalOrder;
quantity = parseFloat(document.frmOrder.BookNumber.value);
totalOrder = quantity * 12.95;
document.frmOrder.Price.value = totalOrder.toFixed(2);
}
function CompareEmail()
{
var Email = document.frmOrder.Email.value;
var ConfirmEmail = document.frmOrder.ConfirmEmail.value;
if ((Email == ConfirmEmail)&&(Email!='')&&(ConfirmEmail!=''))
{
return true;
}
else if (Email == '' || ConfirmEmail == '')
{
alert('Please fill out both email fields.');
return false;
}
else if(Email != ConfirmEmail)
{
alert('Email values are not equal to one another!');
return false;}
}
</script>
<link href="forms.css" rel="stylesheet" type="text/css" />
</head>
<body class="oneColFixCtrHdr">
<div id="container">
<div id="header">
<!-- end #header --></div>
<div id="mainNav">
<ul>
</ul>
</div>
<div id="mainContent">
<div id="rightcolumn">
</div>
<div class="style1" id="leftcolumn" style="position:absolute; width:420px; top:185px;padding-right:5px;">
<h1 class="titles">Manual $12.95 + shipping and handling</h1>
Printed using 100% recycled paper: 68 pages, 8.5" x 11", coil binding, black and white interior ink.<br />
Maufactured using the ECOLITH<span class="style11">®</span> Process.<br />
<br />
<span class="titles"><strong>Description</strong></span><br />
<br />
Learn the basics of how the real estate profession will participate in the new arena of "green." Topics are discussed as an introduction as the first level in the highly acclaimed "Real Estate Environmental and Energy Education Certification Series." This series will be written and produced over the next 4 years, with collaboration by "green building" experts knowledgeable in all phases of the "green" built structure.
<p> </p>
<FORM METHOD="POST" ACTION="mailto:?&subject=Green Manual Order!! " ENCTYPE="text/plain" method="post" name="frmOrder" onsubmit="return CompareEmail();">
<legend></legend>
<label for="required1"><span>*</span>Email</label>
<input type="text" name="Email" id="Email*" /><br />
<label for="required2"><span>*Confirm Email</span></label>
<input type="text" name="ConfirmEmail"/><br />
<label for="BookOrder">Number of Books</label>
<input type="text" name="BookNumber" size="5" maxlength="5" id="Number of Books" onchange="calculate()" value="0" />
<input type="button" value="Calculate" name="btnCalculate" onClick="calculateOrder()"><br />
<label for="Price">Price$</label>
<input type="text" name="Price" size="10" maxlength="15" id="Price of Books" /> (+ Shipping and Handling and Taxes)<br />
<br/>
<input type="submit" value="Submit"><br />
<label for="Confirm">We will call you to confirm your order, shipping,
and payment details.</label><br /><br />
</fieldset>
</form>
</div>
</div>
</body>
</html>
|
If you have further more questions, feel free to ask, as I or other members will help you (I we can)  |
|
| Back to top |
|
 |
mcbc
Joined: 21 May 2008 Posts: 12
|
Posted: Thu May 22, 2008 2:36 pm Post subject: Re: Not validating emails. |
|
|
| Hey, thanks alot for the reply, it is working now, I spent quite a bit of time trying to get that to work. Thank you very much! |
|
| Back to top |
|
 |
|
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums. Click here to Register
If you are a current member here on DEVPPL, please login below:
|
|
|
|