473,808 Members | 2,758 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

4 New Member
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 2098
gits
5,390 Recognized Expert Moderator Expert
what have you done so far? i guess you already have a JavaScript-function called validate_form()?
Aug 29 '09 #2
jmurphy
4 New Member
no haven't done that yet
Aug 31 '09 #3
gits
5,390 Recognized Expert Moderator Expert
so start to implement something and post back with particular problems that occur during your efforts ...

kind regards
Aug 31 '09 #4
jmurphy
4 New Member
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
jmurphy
4 New Member
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
1347
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 control in that event works find but i can't firgure out to use a DataGrid instead. Can someone help, Please.? Dim m_success As Boolean Public Sub ValidationEventHandle(ByVal sender As Object, ByVal args As ValidationEventArgs)
2
2368
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 message to tell the user if all the fields have been fill-out. If the user has missed some information the form re-displays with red "alerts" indicating where the user have missed the information while re-populating the information the user has...
3
4839
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. User comes to our web site and validates themselves as a member of our database. 2. User creates a user name and password to be used to log in to our site. 3. User is required to enter a valid e-mail address to finalize
26
2893
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: error: using obsolete binding at 'j'
2
2856
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 genre="novel" style="hardcover">
1
4009
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. Depends on the pull down list selection, I use script.aculo.us to validate the user input before submit and pass the necessary data, such as contact type, contact information and ranking to a php program for updating. This form should allow multiple...
1
2842
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 am working with is using .asp. Their are 30 multiple choice questions. Each will have have 3 or 4 checkboxes where the test taker will choose only 1 answer per question. Anybody have any ideas as to the best way to validate that each question has...
5
3034
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 method within that class to calculate the weekly pay. Once stop is entered as the employee name, the application should terminate. Make sure the code is readable and well documented. This is what I have done is this correct, as per the parameters...
1
6343
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 the following "DateTextBox" class module). Whenever a user enters in to the textbox, the code displays "Please enter date in mm/dd/yyyy format (for ex: 01/01/2009)." message which is accomplished using "MouseUp" event. And, I used "Exit" event to...
0
9600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10631
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10114
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.