473,378 Members | 1,500 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

i want to validate the following code to ensure tha user enter first name, last name

What do i add to this script to validate the entry?
Thanks in advance for the help.

Expand|Select|Wrap|Line Numbers
  1. <form name="continue" method="POST" action="shipping1.asp" onsubmit="return validate_form ();">
  2.       <input type="hidden" name="subhand" value="<%= subhand %>"><input type="hidden" name="subship" value="<%= subship %>"><input type="hidden" name="subquantity" value="<%= subquantity %>"><input type="hidden" name="subsize" value="<%= subsize %>"><input type="hidden" name="subtotal" value="<%= subtotal %>"><input type="hidden" name="subweight" value="<%= subweight %>"><div align="center"><center>
  3.         <table border="0" cellspacing="1" width="640" bordercolor="#808080" bordercolorlight="#C0C0C0" bordercolordark="#808080" cellpadding="4" style="border-collapse: collapse">
  4.         <tr>
  5.           <td bgcolor="#000000" colspan="4" align="center">
  6.           <font color="#FFFFFF"><img border="0" src="blank.gif"><strong><font face="Arial" size="2">FOR FUTURE 
  7.             ORDERS</font></strong></font></td>
  8.         </tr>
  9.         <tr>
  10.           <td bgcolor="#FFCC66" colspan="4" style="height: 37px">
  11.             <strong>
  12.             <font face="Arial" style="font-size: 9pt">Define
  13.             a Customer Password
  14.             </font></strong>
  15.             <font color="#000080" style="font-size: 9pt" face="Arial">
  16.             <input type="text" name="Password" size="20" value="<%= password%>" class="form_field"></font><font style="font-size: 9pt" face="Arial">&nbsp;&nbsp;&nbsp;&nbsp; </font>
  17.             <font color="#000080" style="font-size: 9pt" face="Arial">
  18.           <input type="checkbox" name="MailingList" value="Yes" checked><font style="font-size: 9pt" face="Arial"> </font></font>
  19.             <font style="font-size: 9pt" face="Arial">
  20.             Please Add me to your Mailing List</font></td>
  21.         </tr>
  22.         <tr>
  23.           <td bgcolor="#000080" width="20" rowspan="7" align="center"><strong>
  24.           <font face="Arial" size="3" color="#FFFFFF">S<br>
  25.           H<br>
  26.           I<br>
  27.           P</font></strong><p><strong>
  28.           <font face="Arial" size="3" color="#FFFFFF">T<br>
  29.           O</font></strong><p></td>
  30.           <td width="33%" valign="top" align="left" bgcolor="#E6E6E6"><strong>
  31.           <font size="1" color="#000080" face="Arial">Company
  32.           Name</font><font size="2" color="#00FF00" face="Arial"><br>
  33.             </font></strong>
  34.           <input name="shipcompany" size="23" value="<%= shipcompany%>" class="form_field"></td>
  35.           <td width="33%" valign="top" align="left" bgcolor="#E6E6E6">
  36.           <p class="form_field"><strong>
  37.           <font color="#000080" face="Arial" size="1">First
  38.           Name</font><font color="#00FF00" face="Arial" size="2"><br>
  39.             </font></strong>
  40.  
Aug 28 '09 #1
5 2061
gits
5,390 Expert Mod 4TB
what have you done so far? i guess you already have a JavaScript-function called validate_form()?
Aug 29 '09 #2
no haven't done that yet
Aug 31 '09 #3
gits
5,390 Expert Mod 4TB
so start to implement something and post back with particular problems that occur during your efforts ...

kind regards
Aug 31 '09 #4
i added this little bit of code before the <title>

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/javascript">
  2. <!--
  3. function checkform ( form )
  4. {
  5.  
  6.   // ** START **
  7.   if (form.shipcompany.value == "") {
  8.     alert( "Please enter a Company Name." );
  9.     form.companyname.focus();
  10.     return false ;
  11.   }
  12.  
  13.   // ** END **
  14.   return true ;
  15. }
  16. //-->
  17. </script>
still allows empty fields
Aug 31 '09 #5
Expand|Select|Wrap|Line Numbers
  1. <title>Order Details</title>
  2. <link rel="stylesheet" type="text/css" href="formpage.css">
  3. <style type="text/css">
  4. .style1 {
  5.     font-size: xx-small;
  6.     font-family: Arial;
  7. }
  8. </style>
  9. <head>
  10. <script type="text/javascript"><!--
  11.  
  12. function validateForm() {
  13. with (document.Continue) {
  14. var alertMsg = "The following REQUIRED fields\nhave been left empty:\n";
  15. if (shipfname.value == "") alertMsg += "\nPlease enter First Name";
  16. if (shiplname.value == "") alertMsg += "\nPlease enter Last Name";
  17. if (shipaddress.value == "") alertMsg += "\nPlease enter Shipping Address";
  18. if (shipzip.value == "") alertMsg += "\nPlease enter Zip Code";
  19. if (shipphone.value == "") alertMsg += "\nPlease enter Contact Number";
  20. if (shipemail.value == "") alertMsg += "\nPlease enter Email";
  21. if (alertMsg != "The following REQUIRED fields\nhave been left empty:\n") {
  22. alert(alertMsg);
  23. return false;
  24. } else {
  25. return true;
  26. } } }
  27. // --></script>
  28.  
  29.  
  30. <body bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0" topmargin="0" bgcolor="#FFFFFF" link="#FF0000" vlink="#FF0000" alink="#FF0000">
  31.  
  32. <div align="center">
  33.   <center>
  34. <!--#include file="header_shop.inc"-->
  35.  
  36. <table border="0" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse" bordercolor="#111111">
  37.   <tr>
  38.     <td width="33%">
  39.           <p align="center">&nbsp;
  40.             </p>
  41.       <form name="continue" onsubmit="return validateForm()" method="POST " action="shipping1.asp">
  42.       <input type="hidden" name="subhand" value="<%= subhand %>"><input type="hidden" name="subship" value="<%= subship %>"><input type="hidden" name="subquantity" value="<%= subquantity %>"><input type="hidden" name="subsize" value="<%= subsize %>"><input type="hidden" name="subtotal" value="<%= subtotal %>"><input type="hidden" name="subweight" value="<%= subweight %>"><div align="center"><center>
  43.         <table border="0" cellspacing="1" width="640" bordercolor="#808080" bordercolorlight="#C0C0C0" bordercolordark="#808080" cellpadding="4" style="border-collapse: collapse">
  44.         <tr>
  45.           <td bgcolor="#000000" colspan="4" align="center">
  46.           <font color="#FFFFFF"><img border="0" src="blank.gif"><strong><font face="Arial" size="2">FOR FUTURE 
  47.             ORDERS</font></strong></font></td>
  48.         </tr>
  49.         <tr>
  50.           <td bgcolor="#FFCC66" colspan="4">
  51.             <strong>
  52.             <font face="Arial" style="font-size: 9pt">Define
  53.             a Customer Password
  54.             </font></strong>
  55.             <font color="#000080" style="font-size: 9pt" face="Arial">
  56.             <input type="text" name="Password" size="20" value="<%= password%>" class="form_field"></font><font style="font-size: 9pt" face="Arial">&nbsp;&nbsp;&nbsp;&nbsp; </font>
  57.             <font color="#000080" style="font-size: 9pt" face="Arial">
  58.           <input type="checkbox" name="MailingList" value="Yes" checked><font style="font-size: 9pt" face="Arial"> </font></font>
  59.             <font style="font-size: 9pt" face="Arial">
  60.             Please Add me to your Mailing List</font></td>
  61.         </tr>
  62.         <tr>
  63.           <td bgcolor="#000080" width="20" rowspan="7" align="center"><strong>
  64.           <font face="Arial" size="3" color="#FFFFFF">S<br>
  65.           H<br>
  66.           I<br>
  67.           P</font></strong><p><strong>
  68.           <font face="Arial" size="3" color="#FFFFFF">T<br>
  69.           O</font></strong><p></td>
  70.           <td width="33%" valign="top" align="left" bgcolor="#E6E6E6"><strong>
  71.           <font size="1" color="#000080" face="Arial">Company
  72.           Name</font><font size="2" color="#00FF00" face="Arial"><br>
  73.             </font></strong>
  74.           <input name="shipcompany" size="23" value="<%= shipcompany%>" class="form_field"></td>
  75.           <td width="33%" valign="top" align="left" bgcolor="#E6E6E6">
  76.           <p class="form_field"><strong>
  77.           <font color="#000080" face="Arial" size="1">First
  78.           Name</font><font color="#00FF00" face="Arial" size="2"><br>
  79.             </font></strong>
  80.           <input type="text" name="shipfname" size="23" value="<%= shipfname%>" class="form_field"></td>
  81.           <td width="33%" valign="top" align="left" bgcolor="#E6E6E6"><strong>
  82.           <font color="#000080" face="Arial" size="1">Last
  83.           Name</font><font color="#00FF00" face="Arial" size="2"><br>
  84.             </font></strong><font size="2" color="#00FF00" face="Arial">
  85.           <input type="text" name="shiplname" size="23" value="<%= shiplname%>" class="form_field"></font></td>
  86.         </tr>
  87.         <tr>
  88.           <td width="66%" valign="top" align="left" bgcolor="#E6E6E6" colspan="2"><strong>
  89.           <font size="1" color="#000080" face="Arial">Address</font><font size="2" color="#00FF00" face="Arial"><br>
  90.             </font></strong><font size="2" color="#00FF00" face="Arial">
  91.           <input type="text" name="shipaddress" size="52" value="<%= shipaddress%>" class="form_field"></font></td>
  92.           <td width="30%" valign="top" align="left" bgcolor="#E6E6E6">
  93.           <font face="Arial"><strong><font size="1" color="#000080">Email<br>
  94.             </font></strong></font>
  95.           <font size="2" color="#00FF00" face="Arial">
  96.           <input type="text" name="shipemail" size="23" value="<%= shipemail%>" class="form_field"></font></td>
  97.         </tr>
  98.         <tr>
  99.           <td width="30%" valign="top" align="left" bgcolor="#EEEEEE">
  100.           <font face="Arial"><strong><font size="1" color="#000080">City<br>
  101.             </font></strong></font>
  102.           <font size="2" color="#00FF00" face="Arial">
  103.           <input type="text" name="shipcity" size="23" value="<%= shipcity%>" class="form_field"></font></td>
  104.           <td width="30%" valign="top" align="left" bgcolor="#E6E6E6">
  105.           <strong><font size="1" color="#000080" face="Arial">State or Province<font color=red><B> * Required</B></font><br>
  106.           </font><font size="2" color="#00FF00" face="Arial">
  107. <%     If IsEmpty(shipstate) Or shipstate = "" Then
  108. %>
  109.           <select name="shipstate" size="1" class="form_field">
  110.             <option value="AL" selected>AL-Alabama</option>
  111.             <option value="AR">AR-Arkansas</option>
  112.             <option value="AZ">AZ-Arizona</option>
  113.             <option value="CA">CA-California</option>
  114.             <option value="CO">CO-Colorado</option>
  115.             <option value="CT">CT-Connecticut</option>
  116.             <option value="DC">DC-District of Columbia</option>
  117.             <option value="DE">DE-Delaware</option>
  118.             <option value="FL">FL-Florida</option>
  119.             <option value="GA">GA-Georgia</option>
  120.             <option value="HI">HI-Hawaii</option>
  121.             <option value="IA">IA-Iowa</option>
  122.             <option value="ID">ID-Idaho</option>
  123.             <option value="IL">IL-Illinois</option>
  124.             <option value="IN">IN-Indiana</option>
  125.             <option value="KS">KS-Kansas</option>
  126.             <option value="KY">KY-Kentucky</option>
  127.             <option value="LA">LA-Louisiana</option>
  128.             <option value="MA">MA-Massachusetts</option>
  129.             <option value="MD">MD-Maryland</option>
  130.             <option value="ME">ME-Maine</option>
  131.             <option value="MI">MI-Michigan</option>
  132.             <option value="MN">MN-Minnesota</option>
  133.             <option value="MO">MO-Missouri</option>
  134.             <option value="MS">MS-Mississippi</option>
  135.             <option value="MT">MT-Montana</option>
  136.             <option value="NC">NC-North Carolina</option>
  137.             <option value="ND">ND-North Dakota</option>
  138.             <option value="NE">NE-Nebraska</option>
  139.             <option value="NH">NH-New Hampshire</option>
  140.             <option value="NV">NV-Nevada</option>
  141.             <option value="NJ">NJ-New Jersey</option>
  142.             <option value="NM">NM-New Mexico</option>
  143.             <option value="NY">NY-New York</option>
  144.             <option value="OH">OH-Ohio</option>
  145.             <option value="OK">OK-Oklahoma</option>
  146.             <option value="OR">OR-Oregon</option>
  147.             <option value="PA">PA-Pennsylvania</option>
  148.             <option value="RI">RI-Rhode Island</option>
  149.             <option value="SC">SC-South Carolina</option>
  150.             <option value="SD">SD-South Dakota</option>
  151.             <option value="TN">TN-Tennessee</option>
  152.             <option value="TX">TX-Texas</option>
  153.             <option value="UT">UT-Utah</option>
  154.             <option value="VA">VA-Virginia</option>
  155.             <option value="VT">VT-Vermont</option>
  156.             <option value="WA">WA-Washington</option>
  157.             <option value="WI">WI-Wisconsin</option>
  158.             <option value="WV">WV-West Virginia</option>
  159.             <option value="WY">WY-Wyoming</option>
  160.                                                   </select> 
  161.           </font></strong>
  162. <%Else%>
  163. <font size="2">
  164.           <input type="text" name="shipstate" size="23" value="<%= shipstate%>" class="form_field"></font>
  165. <%End If%>          </td>
  166.           <td width="30%" valign="top" align="left" bgcolor="#E6E6E6"><strong>
  167.           <font color="#000080" face="Arial" size="1">Zip</font><font color="#00FF00" face="Arial" size="2"><br>
  168.             </font></strong><font size="2" color="#00FF00" face="Arial">
  169.           <input type="text" name="shipzip" size="23" value="<%= shipzip%>" class="form_field"></font></td>
  170.         </tr>
  171.         <tr>
  172.           <td width="32%" valign="top" align="left" bgcolor="#E6E6E6"><strong>
  173.           <font size="1" color="#000080" face="Arial">County</font><font size="2" color="#00FF00" face="Arial"><br>
  174.             </font></strong><font size="2" color="#00FF00" face="Arial">
  175.           <input type="text" name="shipcounty" size="23" value="<%= shipcounty%>" class="form_field"></font>
  176. </td>
  177.           <td width="30%" valign="top" align="left" bgcolor="#E6E6E6"><strong>
  178.           <font size="1" color="#000080" face="Arial">Telephone#</font><font size="2" color="#00FF00" face="Arial"><br>
  179.             </font></strong><font size="2" color="#00FF00" face="Arial">
  180.           <input type="text" name="shipphone" size="23" value="<%= shipphone%>"></font></td>
  181.           <td width="30%" valign="top" align="left" bgcolor="#E6E6E6"><strong>
  182.           <font color="#000080" face="Arial" size="1">Fax#</font><font color="#00FF00" face="Arial" size="2"><br>
  183.             </font></strong><font size="2" color="#00FF00" face="Arial">
  184.           <input type="text" name="shipfax" size="23" value="<%= shipfax%>"></font><table style="width: 100%">
  185.               <tr>
  186.                   <td style="height: 45px"><span class="style1"><strong>How did 
  187.                   you hear about us?</strong></span><br>
  188.                   <select name="How_did_u_hear_about_us" style="width: 168px">
  189.                   <option>None</option>
  190.                   <option>Exsisting Customer</option>
  191.                   <option>Wholesale Central</option>
  192.                   <option>Google</option>
  193.                   <option>Yahoo</option>
  194.                   <option>Inet</option>
  195.                   <option>Other</option>
  196.                   </select>&nbsp;</td>
  197.               </tr>
  198.           </table>
  199.             </td>
  200.         </tr>
  201.         <tr>
  202.           <td width="32%" valign="top" align="left" bgcolor="#E6E6E6"><strong>
  203.           <font size="1" color="#000080" face="Arial">Country</font><font size="2" color="#00FF00" face="Arial"><br>
  204.             </font></strong><font color="#00FF00" face="Arial"><%     If IsEmpty(shipcountry) Or shipcountry = "" Then
  205. %>
  206. <font size="2">
  207. <select NAME="shipcountry" size="1" class="form_field">
  208.             <option SELECTED VALUE="US">United States </option>
  209.           </select> </font></font>
  210. <%Else%>
  211. <font size="2">
  212.           <input type="text" name="shipcountry" size="23" value="<%= shipcountry%>" class="form_field"></font>
  213. <%End If%>
  214. </td>
  215.           <td width="30%" valign="top" align="left" bgcolor="#E6E6E6">
  216.     <strong><font face="Arial" size="1" color="#000080">Resale#</font><font size="2" color="#00FF00" face="Arial"><br>
  217.             </font></strong><font size="2" color="#00FF00" face="Arial">
  218.           <input type="text" name="shipresale" size="23" value="<%= shipresale%>"><br>
  219.     </font><b><font size="1" face="Arial">
  220.           CA Customers <u>MUST</u> provide their Resale Number</font></b></td>
  221.           <td width="30%" valign="top" align="left" bgcolor="#E6E6E6">
  222.           <font face="arial, helvetica ">
  223.           <strong><font color="#000080" size="1"><font color="#FF0000">
  224.           NO P.O. BOX SHIPPING PLEASE. </font><BR>The 48 US contiguous states (domestic) orders only - For 
  225.           Alaska, Hawaii, Virgin Islands, Puerto Rico, or International Orders, 
  226.     Please Email Us For Shipping Info: <a href="mailto:shipping@sharkeyes.com">shipping@sharkeyes.com</a>&nbsp;</font></strong></font></td>
  227.         </tr>
  228.  
  229. <!--      <tr>


Still no pop up alert. Can anyone tell me what's wrong?
Sep 2 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: MG | last post by:
The following below is Microsoft sample to validate a XML document. My question is how can I put the validate errors in DataGrid? Using the ValidationEventHandle subroutine and adding ListBox...
2
by: Tim Mills | last post by:
The following code asks the user to sumbit a name, email address, and some text for a quotation via a FORM. I have written a javascript function to evaluate the fields in the form and pop-up a...
3
by: Wm. Scott Miller | last post by:
Hello all: I'd like some advice on the best way to validate and confirm an e-mail address entered during a registration process. What we are thinking of is something like the following: 1. ...
26
by: Martin Jørgensen | last post by:
Hi, I don't understand these errors I get: g++ Persort.cpp Persort.cpp: In function 'int main()': Persort.cpp:43: error: name lookup of 'j' changed for new ISO 'for' scoping Persort.cpp:37:...
2
by: Doru Roman | last post by:
Hi, I use C# to validate an XML document. It issues error messages and I do not understand why. Here is the XML document: <bookstore xmlns="http://tempuri.org/books.xsd"> <book...
1
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. ...
1
by: mbarnhizer | last post by:
Hello All, Trying to figure out how to validate a series of questions on an online test. I am thinking that VB or Javascript is the best route, but your input may make a difference. The site i...
5
by: hammer45 | last post by:
Modify payroll program so that it uses a class to store and retrive the employee's name, hourly rate and the number of hours worked. Use a constructor to initialize the employee information, and a...
1
by: JFKJr | last post by:
Hello everyone, the following Access VBA code opens an excel file and creates textboxes in a given range of cells dynamically. The code attaches "MouseUP" and "Exit" events to the textboxes (using...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.