SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Wizard dethfire's Avatar
    Join Date
    Aug 2000
    Posts
    2,477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    stumped on validation

    Code:
    <script language="JavaScript">
    
    
    
    function send_onclick()
    {
    
    var bolSubmit;
    bolSubmit = true;
    
    if (document.rfq.02_customer.value == "")
     {
     
     alert("You must enter an company name");
     bolSubmit = false;
    
     }
    
    if (document.rfq.06_contact.value == "")
     {
     
     alert("You must enter a contact name");
     bolSubmit = false;
    
     }
     if (document.rfq.06b_email.value == "")
     {
     
     alert("You must enter an email address");
     bolSubmit = false;
    
     }
     if (document.rfq.07_phone.value == "")
     {
     
     alert("You must enter an telepone number");
     bolSubmit = false;
    
     }
     
     if (bolSubmit == true) 
     
     {
     
    rfq.submit(rfq);
     
     }
    
    
    }
    
    </script>
    Code:
    <form name="rfq" method=post action="http://www.onyourmark.com/cgi-bin/mailform.cgi">
     
    <p>Company Name:<br><input name="02_customer" type="TEXT" size="20"></p>
    <p>Contact Name:<br><input name="06_contact" type="TEXT" size="20"></p>
    <p>Email:<br><input name="06b_email" type="TEXT" size="20"></p>
    <p>Phone:<br><input name="07_phone" type="TEXT" size="20"></p>
               <input name="butsent" type="button" value="Submit this Quotation" language="javascript" onclick="return send_onclick();">
    I click the button and nothing happens
    Free Science Homework Help
    http://www.physicsforums.com

  2. #2
    SitePoint Zealot LiamW's Avatar
    Join Date
    Mar 2003
    Location
    Hamilton, Ontario
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Remove the numbers from the name of each input and in the javascript.

    So for example change 02_customer to customer

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change your entire method.
    Code:
    <form name="rfq" method=post action="http://www.onyourmark.com/cgi-bin/mailform.cgi" onsubmit="return send_onclick(this)">
    
    <input name="butsent" type="submit" value="Submit this Quotation">
    
    function send_onclick(oForm)
    {
     if (oForm.customer_02.value == "" )
    {
     alert("You must enter an company name" );
     return false;
    }
    if (oForm.contact_06.value == "" )
    {
     alert("You must enter a contact name" );
     return false;
    }
     if (oForm.email_06b.value == "" )
    {
     alert("You must enter an email address" );
     return false;
    }
     if (oForm.phone_07.value == "" )
    {
     alert("You must enter an telephone number" );
     return false;
    }
     return true;
    }
    Last edited by adios; May 29, 2003 at 09:50.

  4. #4
    SitePoint Wizard dethfire's Avatar
    Join Date
    Aug 2000
    Posts
    2,477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    adios, i used your suggestion, but still nothing happens

    The method is just not being loaded.
    Free Science Homework Help
    http://www.physicsforums.com

  5. #5
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script language="JavaScript">
    function send_onclick()
    {
    
    if (document.rfq.02_customer.value == "" )
    {
    
    alert("You must enter an company name" );
    return false;
    
    }
    
    if (document.rfq.06_contact.value == "" )
    {
    
    alert("You must enter a contact name" );
    return false;
    
    }
    if (document.rfq.06b_email.value == "" )
    {
    
    alert("You must enter an email address" );
    return false;
    
    }
    if (document.rfq.07_phone.value == "" )
    {
    
    alert("You must enter an telepone number" );
    return false;
    }
    } // end of function
    </script>
    Code:
    <form name="rfq" method=post action=http://www.onyourmark.com/cgi-bin/mailform.cgi onSubmit="return send_onclick()">
    
    <p>Company Name:<br><input name="02_customer" type="TEXT" size="20"></p>
    <p>Contact Name:<br><input name="06_contact" type="TEXT" size="20"></p>
    <p>Email:<br><input name="06b_email" type="TEXT" size="20"></p>
    <p>Phone:<br><input name="07_phone" type="TEXT" size="20"></p>
    <input name="butsent" type="submit" value="Submit this Quotation">
    That's all you need to do. You just need to check each field and return false if any if-then statement evaluates to true. There is no need for the other crap you had in there -- like the variable that was either true or false.

  6. #6
    SitePoint Wizard dethfire's Avatar
    Join Date
    Aug 2000
    Posts
    2,477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmmm, i plug that all in and still nothing happens. The fuction just doesn't fire off. Even if I put no if-thens and just put in a simple alert nothing happens, the function doesn't fire.
    Free Science Homework Help
    http://www.physicsforums.com

  7. #7
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Embarrased to say...LiamW was quite right. No leading numbers for element names, even as hashes (didn't realize that). Edited the above (don't forget to alter the element names).

  8. #8
    SitePoint Wizard dethfire's Avatar
    Join Date
    Aug 2000
    Posts
    2,477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok fixed that, but it can't be the problem, the function still doesn't run when I click the submit button
    Free Science Homework Help
    http://www.physicsforums.com

  9. #9
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can't see it from here, paste in exactly what you're using....

  10. #10
    SitePoint Wizard dethfire's Avatar
    Join Date
    Aug 2000
    Posts
    2,477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html><!-- InstanceBegin template="/Templates/second.dwt" codeOutsideHTMLIsLocked="false" -->
    <head>
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>Custom Faberkin Inc.</title>
    <!-- InstanceEndEditable -->
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
    <link href="cf.css" rel="stylesheet" type="text/css">
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    
    function MM_showHideLayers() { //v6.0
      var i,p,v,obj,args=MM_showHideLayers.arguments;
      for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
        if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
        obj.visibility=v; }
    }
    
    
    function send_onclick()
    {
    
    if (document.rfq.customer.value == "" )
    {
    
    alert("You must enter an company name" );
    return false;
    
    }
    
    if (document.rfq.contact.value == "" )
    {
    
    alert("You must enter a contact name" );
    return false;
    
    }
    if (document.rfq.email.value == "" )
    {
    
    alert("You must enter an email address" );
    return false;
    
    }
    if (document.rfq.phone.value == "" )
    {
    
    alert("You must enter an telepone number" );
    return false;
    }
    } // end of function
    
    
    function MM_reloadPage(init) {  //reloads the window if Nav4 resized
      if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
        document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
      else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
    }
    MM_reloadPage(true);
    //-->
    </script>
    <!-- InstanceParam name="gphlayer" type="boolean" value="true" --><!-- InstanceParam name="ac_txtnv" type="boolean" value="true" --><!-- InstanceParam name="wy_txtnv" type="boolean" value="false" --><!-- InstanceParam name="mbg_txtnv" type="boolean" value="false" --><!-- InstanceParam name="cnt_txtnv" type="boolean" value="false" -->
    </head>
    <body leftmargin="05" topmargin="05" marginwidth="05" marginheight="05">
    <div id="menu1" style="position:absolute; width:151; height:253; z-index:4; visibility: hidden; left: 18px; top: 23px;"><img src="menu1.gif" alt="" name="menu1" width="151" height="223" border="0" usemap="#m_menu1" href="../cad_a.htm">
    <map name="m_menu1">
      <area shape="rect" coords="8,198,95,212" href="skirtq1.htm" alt="" >
      <area shape="rect" coords="8,179,84,192" href="cad_a.htm" alt="" >
      <area shape="rect" coords="8,159,124,172" href="skirte.htm" alt="" >
      <area shape="rect" coords="8,139,51,151" href="skirtd.htm" alt="" >
      <area shape="rect" coords="8,119,57,131" href="skirtc.htm" alt="" >
      <area shape="rect" coords="8,100,74,111" href="skirtb.htm" alt="" >
      <area shape="rect" coords="8,79,112,92" href="skirta.htm" alt="" >
    </map>
    </div>
    <div id="menu2" style="position:absolute; width:151; height:209; z-index:5; visibility: hidden; left: 172px; top: 16px;"><img src="menu2.gif" alt="" name="menu2" width="151" height="209" border="0" usemap="#m_menu2" href="../cad_w.htm">
    <map name="m_menu2">
      <area shape="rect" coords="7,188,97,200" href="rfq.htm" alt="" >
      <area shape="rect" coords="7,167,82,181" href="cad_w.htm" alt="" >
      <area shape="rect" coords="7,148,101,160" href="wayg.htm" alt="" >
      <area shape="rect" coords="7,128,71,140" href="wayc.htm" alt="" >
      <area shape="rect" coords="7,108,73,120" href="wayb.htm" alt="" >
      <area shape="rect" coords="7,88,112,99" href="waya.htm" alt="" >
    </map>
    </div>
    <div id="menu3" style="position:absolute; width:151; height:200; z-index:6; visibility: hidden; left: 326px; top: 6px;"><img src="menu3.gif" alt="" name="menu3" width="151" height="200" border="0" usemap="#m_menu3" href="../rfq.htm">
      <map name="m_menu3">
    <area shape="rect" coords="9,178,96,190" href="rfq.htm" alt="" >
    <area shape="rect" coords="8,147,132,170" href="dep_bg.htm" alt="" >
    <area shape="rect" coords="10,126,117,139" href="slck_bg.htm" alt="" >
    <area shape="rect" coords="8,96,86,118" href="txcv_bg.htm" alt="" >
    </map>
    </div>
    <div id="menu4" style="position:absolute; width:156; height:182; z-index:7; visibility: hidden; left: 480px; top: 24px;"><img src="menu4.gif" alt="" name="menu4" width="154" height="241" border="0" usemap="#m_menu4" href="../rfq.htm">
      <map name="m_menu4">
    <area shape="rect" coords="10,215,101,231" href="rfq.htm" alt="" >
    <area shape="rect" coords="10,92,94,116" href="custom.htm" alt="" >
    <area shape="rect" coords="8,185,104,208" href="contract.htm" alt="" >
    <area shape="rect" coords="8,163,68,177" href="utility.htm" alt="" >
    <area shape="rect" coords="9,144,98,157" href="outdoor.htm" alt="" >
    <area shape="rect" coords="8,122,92,137" href="clawn.htm" alt="" >
    </map>
    </div>
    <div id="closey" style="position:absolute; width:800; height:115px; z-index:1; left: 0; top: 0; visibility: hidden;"><a href="javascript:;" onMouseOver="MM_showHideLayers('menu1','','hide','menu2','','hide','menu3','','hide','menu4','','hide','closey','','hide')"><img src="spacer.gif" width="800" height="480" border="0"></a></div>
    
    <div id="gph" style="position:absolute; z-index:2; left: 308px; top: 150; visibility: visible;"> <!-- InstanceBeginEditable name="gph" --><img src="spacer.gif" width="1" height="300"><img src="lineq1.gif" width=278 height=193 alt="Table Dimesions" border="0"><br>
      <br>
    <img src="lineq2.gif" width=151 height=171 alt="Table Mount" border="0"><!-- InstanceEndEditable --></div>
    
    <img name="nav" src="nav.gif" width="640" height="126" border="0" usemap="#m_nav" alt="">
    <!-- InstanceBeginEditable name="hdr" --><img src="arfq_hdr.gif" width="640" height="55"><!-- InstanceEndEditable -->
    <table width="640" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td style="padding-left: 19px; padding-top: 10px; padding-bottom: 10px; padding-right: 350px;">
    	<!-- InstanceBeginEditable name="body" -->
    <form name="rfq" method="post"  action="http://www.onyourmark.com/cgi-bin/mailform.cgi" onsubmit="return send_onclick()">
      <input type="hidden" name="ToEmail" value="sales@faberkin.com">
      <input type="hidden" name="ToName" value="Faberkin On-line Quotation Results: Accordion Guards for Scissors Lifts">
      <input type="hidden" name="NextURL" value="http://www.faberkin.com/thanks.html">
    <p>Company Name:<br><input name="customer" type="TEXT" size="20"></p>
    <p>Contact Name:<br><input name="contact" type="TEXT" size="20"></p>
    <p>Email:<br><input name="email" type="TEXT" size="20"></p>
    <p>Phone:<br><input name="phone" type="TEXT" size="20"></p>
    <p>Address:</p>
    <input name="Address" type="TEXT" size="20"><br>
    <input name="Address2" type="TEXT" size="20">
      <p>City, State</p>
            <input name="City" type="TEXT" size="15">
            <input name="State" type="TEXT" size="2">
         <p>Zip, &amp; Country:</p>
            <input name="Zip" type="TEXT" size="9">
            <input name="Country" type="TEXT" size="15">
    <p>Number of Units:</p>
          <input name="15_numofunits" type="TEXT" size="5">
              <p>Please specify type:</p>
              <select name="type">
                <option>One-Sided Accordion Skirt
                <option>Two-Sided Accordion Skirt
                <option>Three-Sided Accordion Skirt
                <option>Four-Sided Accordion Skirt
                <option>Roller Curtain
              </select>
              <p> <b>**Please call for assistance<br>
                if table is a pit mount.**</b><p>
    				    <h1>Dimensions</h1>  
    	    <p>A = <input type=text size="5" name="22_dima">
              B = <input type=text size="5" name="23_dimb">
              D = <input type=text size="5" name="24_dimd">
            </p>	    <p>E = <input type=text size="5" name="25_dime">
              LH = <input type=text size="5" name="26_dimlh">
              EH =<input type=text size="5" name="27_dimeh"></p>
    		<h1>Options </h1> 
            <p><input type=checkbox name="18_uppersteelmounting"> Upper Steel Mounting</p>        
            <p><input type=checkbox name="19_lowersteelmounting"> Lower Steel Mounting</p>
            <p><input type=checkbox name="20_velcrotop"> Velcro TOP</p>
            <p><input type=checkbox name="20_velcrobottom"> Velcro BOTTOM</p>
            <p><input type=checkbox name="21_maintenenceties"> Maintenence Ties</p>
    		<h1>Table Mounting</h1>
    	    <p>TOP COLLAR: <select name="16_topcollar">
                    <option>A
                    <option>B
                </select></p>
            <p>BOTTOM COLLAR: <select name="17_bottomcollar">
                    <option>A
                    <option>B
                    </select></p>        
               <h1>Comments:</h1>
    		   <textarea name="99_comments" cols="25" rows="5" wrap="physical"></textarea><br><br>
               <input name="butsent" type="button" value="Submit this Quotation">
               <input name="reset" type="reset" value="Clear Form">
    </form>
    <!-- InstanceEndEditable -->	</td>
      </tr>
    </table>
    <map name="m_nav">
      <area shape="rect" coords="477,31,625,100" href="#" alt="" onMouseOver="MM_showHideLayers('menu4','','show','closey','','show')" >
      <area shape="rect" coords="322,31,471,99" href="#" alt="" onMouseOver="MM_showHideLayers('menu3','','show','closey','','show')" >
      <area shape="rect" coords="169,30,317,99" href="#" alt="" onMouseOver="MM_showHideLayers('menu2','','show','closey','','show')" >
      <area shape="rect" coords="13,31,163,99" href="#" alt="" onMouseOver="MM_showHideLayers('menu1','','show','closey','','show')" >
      <area shape="rect" coords="329,107,365,121" href="home.htm">
      <area shape="rect" coords="372,107,429,121" href="aboutus.htm">
      <area shape="rect" coords="435,107,520,122" href="cad.htm">
      <area shape="rect" coords="527,107,556,122" href="rfq.htm">
      <area shape="rect" coords="560,107,627,122" href="#">
    </map>
    
    <div id="ac_txtnv" class="txtnv">
    <a href="skirta.htm">Design & Fabrication</a> | 
    <a href="skirtb.htm">Construction</a> | 
    <a href="skirtc.htm">Mounting</a> | 
    <a href="skirtd.htm">Options</a> | 
    <a href="skirte.htm">Installation Instructions</a> | 
    <a href="cad_a.htm">CAD Drawings</a> | 
    <a href="skirtq1.htm">Request a Quote</a></div>
    
    
    
    
    
    
    
    <table width="640" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="156" rowspan="2"><img src="cf_lgo.gif" width="156" height="54"></td>
        <td width="467" height="25">&nbsp;</td>
      </tr>
      <tr>
        <td style="border-top:solid 1px black;">
    	<p>P.O. Box 1065 | Fond du Lac, Wisconsin 54936-1065<br>
        <strong>920-921-5660</strong> | fax 920-921-2840 | sales@faberkin.com</p>
    </td>
      </tr>
    </table>
    
    </body>
    <!-- InstanceEnd --></html>
    Free Science Homework Help
    http://www.physicsforums.com

  11. #11
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <input name="butsent" type="submit" value="Submit this Quotation">

    No submit button, no submit.

  12. #12
    SitePoint Zealot LiamW's Avatar
    Join Date
    Mar 2003
    Location
    Hamilton, Ontario
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quick tip

    Javascript does not allow you to use a number as the first character in an identifer, so that it can easily distinguish between an identifier and a literal value.

    Also note that by using the method you used at first, by calling the function from the Onclick event of the button, will do nothing if the user hits enter on their keyboard instead of actually pushing the button. This is why it is always good practice to call the function from the onSubmit of the form.

    Do you have it all working now?

  13. #13
    SitePoint Wizard dethfire's Avatar
    Join Date
    Aug 2000
    Posts
    2,477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes thanks all!!
    Free Science Homework Help
    http://www.physicsforums.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •