<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Doctor Web Snake Oil</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilsubscribeia 4.0">
<link type="text/css" rel="stylesheet" href="drwebstyles.css" />


<script language="javascript" type="text/javascript">
<!--
/*
File:       drWeb_dis.v4b.html
Author: Diane Forkin
Date:   23/9/2007
Purpose:    Dr Web Validate Form and all entries


*/



//function for submit button validates all this information
function onSubmit(f) {


fname = f.fname.value;
re = /^[A-Za-z]{2,}$/;
if (f.fname.value == '' || !re.test( f.fname.value )){      //validates first name
alert('Enter at least 2 alpha characters for your First Name');                 //alerts message if name not entered
f.fname.focus();
return false;
}


lname = f.lname.value;
re = /^[A-Za-z]{2,}$/;
if (f.lname.value == '' || !re.test( f.lname.value )){      //validates first name
alert('Enter at least 2 alpha characters for your Last Name');                  //alerts message if name not entered
f.lname.focus();
return false;
}



email = f.email.value;
if (email == ""){                       //validates email
alert('Enter your email');          //alerts message if name not entered
f.email.focus();
return false;
}


re = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
if (!re.test(email)){                       //tests for valid email address
alert('Enter a valid email');           //alerts message if email not valid
f.email.select();
return false;
}


phone = f.phone.value;
re = /^[0-9- ()]{6,12}$/;
if (!re.test(phone)){                       //tests for valid phone number
alert('Enter a valid Phone Number');    //alerts message if phone number not between 6 and 12 digits long
f.phone.select();
return false;
}


card = f.card.value;
re = /^\d{16}$/;
if (!re.test(card)){                           //tests for valid creditcard number
alert('Enter a 16 digit credit card number');      //alerts messages if not valid credit card not 16 digits long
f.card.select();
return false;
}



expiry = f.expiry.value;
re = /^(0[1-9]|1[012])\d\d$/;
if (!re.test(expiry)){                      //tests for expiry date of credit card 4 digits 2 for month 2 for year
alert('Enter a date as mmyy');                 //alerts for date as month and year
f.expiry.select();
return false;
}


index = f.cardtype.options.selectedIndex;
if ( index == -1 ){                                 //tests for cardtype as index of Mastercard, Visa, bankcard or americanex
alert('Select a Card Type');                    //alerts if a credit card type not selected
f.cardtype.focus();                             //'index is drop down menu'
return false;
}
cardtype = f.cardtype.options[index].text;



index = f.pmtplan.options.selectedIndex;
if ( index == -1 ){                                 //tests for payment plan if checked as Annually, Quarterly or Monthly
alert('Select a Payment Plan');                 //alerts if a payment plan has been checked
f.pmtplan.focus();
return false;
}
pmtplan = f.pmtplan.options[f.pmtplan.options.selectedIndex].text;
pmtcost = f.pmtplan.options[f.pmtplan.options.selectedIndex].value;


oil = "";
if ( f.oil[0].checked ){                            //tests to see if a consistency of Snake Oil is has been selected
oil = f.oil[0].value;
} else if ( f.oil[1].checked ){
oil = f.oil[1].value;                           //"THIS IS THE RADIO BUTTONS"
} else if ( f.oil[2].checked ){
oil = f.oil[2].value;
} else {
alert('Select a Snake Oil Consistency');        //alerts if a snake oil consistency hasn't been selected
f.oil[0].select();
return false;
}


num = f.num.value;
if (!isFinite(f.num.value)){
alert('Enter the Number of Computers that will use this oil');
f.num.focus();
return false;
}


comments = f.comments.value;
if (comments == ""){                       //validates last name
alert('Please enter a comment');        //alerts message if name not entered
f.comments.focus();
return false;
}



if (!f.subscribe.checked) {
alert('Please accept Dr Web\'s Terms and Conditions');
f.subscribe.focus();
return false;
} else {
subscribe = 'YES';
}


//works out the cost to the customer by multiplying the oil type by the number of computers using it
if (f.num.value > 1){
cost = eval(f.pmtplan.value) + eval(f.num.value) - 1;
} else {
cost = eval(f.pmtplan.value);
}


onDetails();                                // opens new window with clients information


}


//function of displaying the contents of the validated form in a new window
function onDetails() {
var details = window.open('','','scrollbars,toolbar=yes,width=500,height=550,left=20,top=20');
details.document.write('<html><head><title>DRWEB Details</title>');
details.document.write('<link rel="stylesheet" type="text/css" href="drwebstyles.css" />');
details.document.write('<script type="text/javascript"> function printpage(){ window.print()} </script></head>');
details.document.write('<body class="detailhds" >Your Doctor Web Snake Oil Account Details<br/>');
details.document.write('<p class="read">Please read carefully before you accept. Thankyou!</p>');
details.document.write('<form>');
details.document.write('<table class="tablex" align="center">');
details.document.write('<tr><td class="tdright">First name:&nbsp&nbsp</td><td class="tdleft">' + fname + '</td></tr>');
details.document.write('<tr><td class="tdright">Last name:&nbsp&nbsp</td><td class="tdleft">' + lname +'</td></tr>');
details.document.write('<tr><td class="tdright">Email:&nbsp&nbsp</td><td class="tdleft">' + email + '</td></tr>');
details.document.write('<tr><td class="tdright">Phone number:&nbsp&nbsp</td><td class="tdleft">' + phone + '</td></tr>');
details.document.write('<tr><td class="tdright">Credit card Number:&nbsp&nbsp</td><td class="tdleft">' + card + '</td></tr>');
details.document.write('<tr><td class="tdright">Credit Card Expiry:&nbsp&nbsp</td><td class="tdleft">' + expiry + '</td></tr>');
details.document.write('<tr><td class="tdright">Credit Card type:&nbsp&nbsp</td><td class="tdleft">' + cardtype + '</td></tr>');
details.document.write('<tr><td class="tdright">Payment period:&nbsp&nbsp</td><td class="tdleft">' + pmtplan + '</td></tr>');
details.document.write('<tr><td class="tdright">Snake Oil Consistency:&nbsp&nbsp</td><td class="tdleft">' + oil + '</td></tr>');
details.document.write('<tr><td class="tdright">Number of Computers:&nbsp&nbsp</td><td class="tdleft">' + num + '</td></tr>');
details.document.write('<tr><td class="tdright">Comments:&nbsp&nbsp</td><td class="tdleft">' + comments + '</td></tr>');
details.document.write('<tr><td class="tdright">Subscribe:</td><td class="tdleft">' + subscribe + '</td></tr>');
details.document.write('<tr><td class="tdright">Amount Credited to Card:&nbsp&nbsp</td><td class="tdleft">' + cost.toFixed(2) + '</td>&nbsp;</tr>');
details.document.write('</table>');
details.document.write('<table align="center">');
details.document.write('<tr><td class="tdbutns"><input type="button" name="accept" value="Accept"');
details.document.write('onClick="self.close();opener.document.drweb.submit();"/>&nbsp&nbsp&nbsp');
details.document.write('<input type="button" name="decline" value="Decline"');
details.document.write('onClick="self.close();return false";/>&nbsp&nbsp&nbsp');


details.document.write('<input type="button" name="print" value="   Print  "');
details.document.write(' onClick="printpage()" /></td></tr>');


details.document.write('<tr><td>&nbsp</td></tr>');
details.document.write('<tr><td colspan="2" class="created">Created by Diane Forkin');
details.document.write('</td></tr></table></form></body></html>');
}


//-->


</script>



</head>


<body bgcolor="#000000"  onload="window.setTimeout('document.forms[0].reset()', 1000*60*2);"    >
<center>
<p class="super">Snake Oil Subscription</P>
<p class="name">Doctor Web</P>
<p class="sub"> Account Application</P>
<br><br><br><br><br>


<form  name="drweb" action="donedeal.html" method="POST" enctype="text/plain" >


<table width="75%" border="1" cellspacing="0" cellpadding="4" bgcolor="#c0c0c0" bordercolor="gray">
<tr>
<th bgcolor="#666666" colspan="2" align="left">
<b>
<font size="3" color="#FFCC66" face="verdana, arial, helvetica">
Fill in your details and submit this form</font></b>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font size="2" color="#FFFDED" face="verdana, arial, helvetica">
<b><i> All fields are required</i></b></font>
</th>
</tr>
<tr>
<td width="27%"><b>First name</b></td>
<td><input type="text" name="fname" size="20" maxlength="30" value=""></td>
</tr>
<tr>
<td><b>Last name</b></td>
<td><input type="text" name="lname" size="40" maxlength="40" value=""></td>
</tr>
<tr>
<td><b>Email</b></td>
<td><input type="text" name="email" size="40" maxlength="80" value=""></td>
</tr>
<tr>
<td><b>Phone number</b></td>
<td><input type="text" name="phone" size="20" maxlength="30" value="">
&nbsp;&nbsp;<i>Your day time contact number</i></td>
</tr>
<tr>
<td><b>Credit card number</b></td>
<td><input type="text" name="card" size="20" maxlength="16" value="">
<i>&nbsp;&nbsp;Your 16 digit card number</i></td>
</tr>
<tr>
<td><b>Credit card expiry</b></td>
<td><input type="text" name="expiry" size="6" maxlength="4" value="">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<i>Enter as 'mmyy' eg 0105</i></td>
</tr>
<tr>
<td><b>Credit card type</b></td>
<td>
<select name="cardtype">
<option> MasterCard
<option> Visa
<option> BankCard
<option> American Express
</select>
<i>&nbsp;&nbsp;&nbsp;&nbsp;Only these cards are accepted. Thankyou.</i></td>
</tr>
<tr>
<td><b>Payment period</b></td>
<td>
<select name="pmtplan">
<option value=199.95> Annually
<option value=45.95> Quarterly
<option value=19.95> Monthly
</select>
<i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;
Choose one of these advance payment options</i></td>
</tr>
<tr>
<td><b>Snake Oil Consistency</b></td>
<td>
<input type="radio" name="oil" value="Thin">Thin<br />
<input type="radio" name="oil" value="Thick">Thick<br />
<input type="radio" name="oil" value="Thicker">Thicker
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Number of computers that will use this oil
<input type="text" name="num" size="3" maxlength="2" value="1">
</td>
</tr>
<tr>
<td><b>Comments</b></td>
<td>
<i>Tell us why you chose Doctor Web and win free Snake Oil. <br />A winner every month!</i><br />
<textarea name="comments" rows="3" cols="40"></textarea>
</td>
</tr>
<tr>
<td><b>Terms and conditions</b></td>
<td>
<input type="checkbox" name="subscribe" value="" checked="true">
<i>I accept Doctor Web's</i> <a href="terms.html" alt="Gotcha!">
terms and conditions</a>&nbsp;<i>and subscribe to Snake Oil</i>


<input type="button" value="Submit" onClick="onSubmit(this.form);">
<input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<b><font size="2" color="#FF3333" face="verdana, arial, helvetica">Doctor Web</font><br>
<font size="2" color="#FF3333" face="verdana, arial, helvetica">Secure Payment Account Application   </font></b>
</center>


</body>


</html>

Recommended Answers

All 2 Replies

your problem is that the window doesnt load completely. Im not sure where the error is though. You could have a pre generated page where you pass on the variables.

thanks heaps. I'm still not sure how to fix it though

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.