Emptrix Staff Administrator
Posts : 1218 Points : 1916 Reputation : 13 Join date : 2009-05-09 Age : 33 Location : The World That Never Was
| Subject: (Requested) Check for Items code - HTML & Javascript Tue Nov 16, 2010 12:12 pm | |
| As requested by Burma, here: - Code:
-
<!Author: Emptrix>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html> <head> <meta name="generator" content= "HTML Tidy for Windows (vers 14 February 2006), see www.w3.org"> <title>Practice Exercise 6</title> <script type="text/javascript"> function check() { var pc = document.product_form.p_code.value; var pd = document.product_form.p_desc.value; var p = document.product_form.price_txt.value; if (pc == "") { alert("Please enter a product code."); document.product_form.p_code.focus(); } else if (pc.length != 6) { alert("Your product code must be 6 digits."); document.product_form.p_code.focus(); } else if (isNaN(pc)) { alert("Product code must be in numbers only."); } else if (pd == "") { alert("Please enter a product desc."); document.product_form.p_desc.focus(); } else if (p < 20 || p > 40) { alert("Price range is out of bound. Please enter a price within $20 to $40."); document.product_form.p.focus(); } else if (document.product_form.shirt_category.options[0].selected) { alert("Please select a shirt category."); } else { var request = confirm("Your Shirt has been successfully sent to us!"); if (request == false) { alert("Submit was canceled"); } else { window.open("confirmpage.html"); } } } </script> </head> <body> <form name="product_form" allow="" method="post"> <table> <tr> <td>Product Code: </td> <td><input type="text" name="p_code" value="" onBlur="check()" /></td> </tr> <tr> <td>Product Desc: </td> <td><input type="text" name="p_desc" value="" onBlur="check()" /></td> </tr> <tr> <td>Price: </td> <td><input type="text" name="price_txt" value="" onBlur="check()" /></td> </tr> <tr> <td>Shirt Category: </td> <td> <select name="shirt_category"> <option value="">Select Here</option> <option value="round neck">Round Neck</option> <option value="v neck">V Neck</option> </select> </td> </tr> <tr> <td></td> <td><input type="button" name="button" value="Sent Your Shirt!" onClick="check()" /></td> </tr> </table> </form> </body> </html>
| |
|