<html> <head> <title>order from example</title> <script language="javascript"> <!-- hide this script from non-javascript-enbled browsers function isANumber(inputvalue){ var result=true if(! parseFloat(inputvalue){ result=false } else{ for(var i=0;i<=inputvalue.length;i++) if(inputvalue.charAt(i)=" "){ if(! parseFloat(inputvalue.charAt(i))){ result=false break } } } }
return result }
function isAvalidE-mail(inputvalue){ var foundAt=flase var foundDot=false for(var i=0;i<=inputvalue.length;i++){ if(inputvalue.charAt(i)=="@"){ foundAt=true } } if(foundAt&&foundDot){ return true } else { return false } }
function isAvalidPhoneNumber(inputvalue){ var digitsfound=0 for(var i=0;i<=inputvalue.length;i++){ if(isANumber(inptvalue.charAt(i))){ digitsfound++ } } if(digitsfound>=10){ return true } else{ return false} }
function exists(inputvalue){ var aCharExists=false for(var i=0;i<=inputvalue.length;i++){
if(inputvalue.chatAt(i)!=" " && inputvalue.chatAt(i)!= ""){ aCharExists=true break } } return aCharExists }
function validateform(){ var rc=true if(!document.quoteForm.designChoice.checked&& !document.quoteForm.mainChoice.checked&& !document.quoteForm.promoChoice.checked){ alert("please check whether yuou're interested in our design,maintenancem, or promotion services so we can give you a more accurate quote. thanks!") rc=false }
if(document.quoteForm.bizChoice[1].checked){ if(!document.quoteForm.corpName.value){ alert("you've specified that you're an employee, so could you please type in the name of the company you work for?thanks!") rc=false } } if(!document.quoteForm.firstName.value||!document.quoteForm.lastName.value){ alert("please type inyour entire name(both first and last). thanks!") rc=false } if(!document.quoteForm.E-mailChoice.checked&&!document.quoteForm.phoneChoice.checked){ alert("please let us know whether you'd like us to contact you by E-mail or by phone thanks!") rc=false } if(document.quoteForm.E-mailChoice.checked&& !isAvalidE-mail(document.quoteForm.E-mailAddr.value)){ alert("we can't contact you via E-mail unless you give us a valid E-mail address. thanks!") rc=false } else{ if(document.quoteForm.phoneChoice.checked&& !isAvalidPhoneNumber(document.quoteForm.phoneNumber.value)){ alert("we can't contact you via phone unless you give us your phone number(make sure to include you are code). thanks!") rc=false } } if(rc){ alert("thanks! we'll contact you with q quote shortly.") } return rc } //--> </script> </head> <body> <h1> order form examples</h1> <hr> <p> <hr> <table width="100%" cellspacing="10" cellpadding="10" border=0> <tr> <td> <font face="Helvetica.Arial,Verdana" size="2"> <form name="quoteForm" onSubmit="return validateform();"> <p> <b> whick of ous services are you interested in?</b> (check all that apply.) <p> Website design<input type="checkbox" name="designChoice" value="design" > Website maintenance <input type="checkbox" name="mainChoice" value="maint"> Online promotion <input type="checkbox" name="promoChoice" value="promo"> <p> <b>why do you want a website? (or, if you already have one ,what do you use it for?)</b> <p> <textarea name="purpose" cols="60" rows="5" wrap="virtual"> </textarea> <p> <b> do you want to incorporate photos into your site?</b> <br> yes <input type="radio" name="pixChoice" value="hasPix" checked> no <input type="radio" name="pixChoice" value="hasNoPix"> <p> <b> do you have one or more products you'd like to promote/ sell on you site?</b> <br> yes <input type="radio" name="cdChoice" value="hasProducts" checked> no <input type="radio" name="cdChoice" value="hasNoProducts"> <p> <b> are you a small businesss owner,or do you work for a large corporation?</b> <br> samll business owner <input type="radio" name="bizChoice" value="isOwner" checked> employee <input type="radio" name="bizChoice" value="isEmployee"> <p> <b> if you work for a corporation,what's the name?</b> <input type="text" name="corpName" size="25"> <p> <b> is there anything else you think we need to know in order to give you an accurate price quote?</b> <p> <textarea name="extrainfo" cols="60" rows="5" wrap="virtual"> </textarea> <p>
<table> <tr> <td> <font face="Helvetica, Arial,Verdana" size="2"> <b> you first name:</b> </td> <td> <font face="Helvetrica, Arial,Verdana" size="2"> <b> last name:</b> </td> </tr> <tr> <td> <input type="text" name="firstname" size="25" onBlur="if(!exists(this.value)){ alert('please enter a first name');}"> </td> <td> <input type="text" name="lastname" size="25" onBlur="if(!exists(this.value)){ alert('please enter a last name');}"> </td> </tr> <tr> </tr>
<tr> <td colspan="2"> <font face="Helevetica,Arial,Verdana"size="2"> <b> how would you like us to contact you(E-mail,phone,or both)?</b> </font> </td> </tr>
<tr> <td align="right"> <font face="Helvetica,Arial,Verdana"size="35"> E-mail<input type="checkbox" name="E-mailChoice"value="E-mail"> </font> </td>
<td> <input type="text" name="E-mailAddr" size="35"> </td> </tr> <tr> <td align="right"> <font face="Helvetica,Arial,Verdana"size="2"> telephone<input type="checkbox" name="phoneChoice" value="phone"> </td> <td> <input type="text" name="phoneNumber" size="15"> </td> </tr> </table> <p> <center> <input type="submit" value="submit you quote request"> <input type="reset" value="clear the form"> </center> </body> </html>
就是在上面<head>和</head>中的函数,在<body></body>中没调用, 无任何结果.
[此贴子已经被作者于2005-4-18 15:59:06编辑过]