•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 456,530 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,846 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 808 | Replies: 2
![]() |
•
•
Join Date: Oct 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
<!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:  </td><td class="tdleft">' + fname + '</td></tr>');
details.document.write('<tr><td class="tdright">Last name:  </td><td class="tdleft">' + lname +'</td></tr>');
details.document.write('<tr><td class="tdright">Email:  </td><td class="tdleft">' + email + '</td></tr>');
details.document.write('<tr><td class="tdright">Phone number:  </td><td class="tdleft">' + phone + '</td></tr>');
details.document.write('<tr><td class="tdright">Credit card Number:  </td><td class="tdleft">' + card + '</td></tr>');
details.document.write('<tr><td class="tdright">Credit Card Expiry:  </td><td class="tdleft">' + expiry + '</td></tr>');
details.document.write('<tr><td class="tdright">Credit Card type:  </td><td class="tdleft">' + cardtype + '</td></tr>');
details.document.write('<tr><td class="tdright">Payment period:  </td><td class="tdleft">' + pmtplan + '</td></tr>');
details.document.write('<tr><td class="tdright">Snake Oil Consistency:  </td><td class="tdleft">' + oil + '</td></tr>');
details.document.write('<tr><td class="tdright">Number of Computers:  </td><td class="tdleft">' + num + '</td></tr>');
details.document.write('<tr><td class="tdright">Comments:  </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:  </td><td class="tdleft">' + cost.toFixed(2) + '</td> </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();"/>   ');
details.document.write('<input type="button" name="decline" value="Decline"');
details.document.write('onClick="self.close();return false";/>   ');
details.document.write('<input type="button" name="print" value=" Print "');
details.document.write(' onClick="printpage()" /></td></tr>');
details.document.write('<tr><td> </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>
<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="">
<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> 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="">
<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> 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>
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
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> <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>
<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:  </td><td class="tdleft">' + fname + '</td></tr>');
details.document.write('<tr><td class="tdright">Last name:  </td><td class="tdleft">' + lname +'</td></tr>');
details.document.write('<tr><td class="tdright">Email:  </td><td class="tdleft">' + email + '</td></tr>');
details.document.write('<tr><td class="tdright">Phone number:  </td><td class="tdleft">' + phone + '</td></tr>');
details.document.write('<tr><td class="tdright">Credit card Number:  </td><td class="tdleft">' + card + '</td></tr>');
details.document.write('<tr><td class="tdright">Credit Card Expiry:  </td><td class="tdleft">' + expiry + '</td></tr>');
details.document.write('<tr><td class="tdright">Credit Card type:  </td><td class="tdleft">' + cardtype + '</td></tr>');
details.document.write('<tr><td class="tdright">Payment period:  </td><td class="tdleft">' + pmtplan + '</td></tr>');
details.document.write('<tr><td class="tdright">Snake Oil Consistency:  </td><td class="tdleft">' + oil + '</td></tr>');
details.document.write('<tr><td class="tdright">Number of Computers:  </td><td class="tdleft">' + num + '</td></tr>');
details.document.write('<tr><td class="tdright">Comments:  </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:  </td><td class="tdleft">' + cost.toFixed(2) + '</td> </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();"/>   ');
details.document.write('<input type="button" name="decline" value="Decline"');
details.document.write('onClick="self.close();return false";/>   ');
details.document.write('<input type="button" name="print" value=" Print "');
details.document.write(' onClick="printpage()" /></td></tr>');
details.document.write('<tr><td> </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>
<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="">
<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> 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="">
<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> 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>
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
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> <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>
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Print button using rollover images (JavaScript / DHTML / AJAX)
- Printing using Web Control Print button VB.NET (JavaScript / DHTML / AJAX)
- Printing using Web Control Print button. (ASP.NET)
- Forms - Print Button (HTML and CSS)
- Forms - Print Button (HTML and CSS)
- Help in printing mulitple documents using print button (Java)
- Strange paw print button among IE6's buttons (Web Browsers)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Toggle div visibility
- Next Thread: How to embed flash player content...


Linear Mode