It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming HTML Forum

Not validating emails.

Not validating emails.

Postby mcbc on Wed May 21, 2008 3:36 pm

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&quot; x 11&quot;, 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 &quot;green.&quot; Topics are discussed as an introduction as the first level in the highly acclaimed &quot;Real Estate Environmental and Energy Education Certification Series.&quot; This series will be written and produced over the next 4 years, with collaboration by &quot;green building&quot; experts knowledgeable in all phases of the &quot;green&quot; built structure.
<p>&nbsp;</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>
mcbc
 
Posts: 14
Joined: Wed May 21, 2008 3:22 pm

Postby rangana on Thu May 22, 2008 1:34 am

When assigning a variable, it should only be = and not ==
Code: Select all
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: Select all
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: Select all
<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&quot; x 11&quot;, 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 &quot;green.&quot; Topics are discussed as an introduction as the first level in the highly acclaimed &quot;Real Estate Environmental and Energy Education Certification Series.&quot; This series will be written and produced over the next 4 years, with collaboration by &quot;green building&quot; experts knowledgeable in all phases of the &quot;green&quot; built structure.
<p>&nbsp;</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) ;)
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Postby mcbc on Thu May 22, 2008 1:36 pm

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!
mcbc
 
Posts: 14
Joined: Wed May 21, 2008 3:22 pm


Who is online

Users browsing this forum: No registered users and 7 guests