Topic: validation not working


awayne    -- 02-02-2006 @ 5:50 PM
  Here is my code... I have gone over and over it again and can't seem to find my mistake:
<InvalidTag language="JavaScript" type="text/javascript">
function validateFields() {
    if (document.form1.pupdate.value == "") {
        alert("Please Enter Your Pickup Date");
        return false;
    }
     if (document.form1.fname.value == "") {
        alert("Please Enter Your First Name");
        return false;
    }
     if (document.form1.lname.value == "") {
        alert("Please Enter Your Last Name");
        return false;
    }
     if (document.form1.htelephone1.value == "") {
        alert("Please Enter Your Complete Telephone Number");
        return false;
    }
     if (document.form1.htelephone2.value == "") {
        alert("Please Enter Your Complete Telephone Number");
        return false;
    }
     if (document.form1.htelephone3.value == "") {
        alert("Please Enter Your Complete Telephone Number");
        return false;
    }
     if (document.form1.zip1.value == "") {
        alert("Please Enter The Origin Zip Code");
        return false;
    }
     if (document.form1.zip2.value == "") {
        alert("Please Enter The Destination Zip Code");  
       return false;
    }
return true;
}
</script>


Thanks
Wayne

This message was edited by awayne on 2-2-06 @ 5:50 PM


falconseye    -- 02-02-2006 @ 5:55 PM
  JavaScript is case sensitive so i would check the form fields and see if their names are exactly the same in your JavaScript calls. also, i assume your form name is called = form1 ?

finally, how do you call validateFields() ? Can you post your form code?


awayne    -- 02-02-2006 @ 6:04 PM
  I just made a change to that form name from form1 to quote1 so it is not so confussing.  Here is the form code, I didn't include the whole page, just the part that includes the parts I am trying to validate.  Thanks for the help.

<form name="quote1" method="post" action="quote2.cfm" onsubmit="return validateFields();">
        <table width="100%" border="0" cellspacing="0" cellpadding="1">
          <tr bgcolor="#CC0000">
            <td height="19" colspan="4" class="BodyText"><font color="#FFFFFF"><strong>Contact
              Information</strong></font></td>
          </tr>
          <tr bgcolor="#CCCCCC">
            <td height="24" class="BodyText"><p>*Pickup Date</p>
              </td>
            <td class="BodyText"><input name="pudate1" type="text" class="FormInput" value="MM" size="1" maxlength="2">
              <input name="pudate2" type="text" class="FormInput" value="DD" size="1" maxlength="2">
              <input name="pudate3" type="text" class="FormInput" value="YYYY" size="1" maxlength="4"></td>
            <td class="BodyText">Delivery By</td>
            <td><input name="ddate1" type="text" class="FormInput" value="MM" size="1" maxlength="2">
              <input name="ddate2" type="text" class="FormInput" value="DD" size="1" maxlength="2">
              <input name="ddate3" type="text" class="FormInput" value="YYYY" size="1" maxlength="4"></td>
          </tr>
          <tr bgcolor="#CCCCCC">
            <td class="BodyText">*First Name <b></b></td>
            <td class="BodyText"><input name="fname" type="text" class="FormInput"></td>
            <td class="BodyText">*Last Name <b></b></td>
            <td><input name="lname" type="text" class="FormInput" value=""></td>
          </tr>
          <tr bgcolor="#CCCCCC">
            <td class="BodyText">*Home Phone<b></b></td>
            <td class="BodyText"><input name="htelephone1" type="text" class="FormInput" size="1" maxlength="3">
              <input name="htelephone2" type="text" class="FormInput" size="1" maxlength="3">
              <input name="htelephone3" type="text" class="FormInput" value="" size="1" maxlength="4"></td>
            <td class="BodyText">Work/Cell Phone<b></b></td>
            <td class="BodyText"><input name="wtelephone1" type="text" class="FormInput" size="1" maxlength="10">
              <input name="wtelephone2" type="text" class="FormInput" size="1" maxlength="10">
              <input name="wtelephone3" type="text" class="FormInput" size="1" maxlength="10"></td>
          </tr>
          <tr bgcolor="#CCCCCC">
            <td class="BodyText">*E-mail Address</td>
            <td class="BodyText"><input name="email" type="text" class="FormInput" value=""></td>
            <td colspan="2">&nbsp; </td>
          </tr>
          <tr bgcolor="#CCCCCC">
            <td class="BodyText">*Contact Via<b></b></td>
            <td class="BodyText"><select name="select1" class="FormInput">
                <option>Please Select One</option>
                <option value="Email">Email</option>
                <option value="Telephone">Telephone</option>
              </select></td>
            <td class="BodyText">Best Time<b></b></td>
            <td><select name="select2" class="FormInput">
                <option>Please Select One</option>
                <option value="Day">Day </option>
                <option value="Night">Night </option>
                <option value="Weekend">Weekend </option>
                <option value="Anytime">Anytime </option>
              </select></td>
          </tr>
          <tr>
            <td colspan="4" bgcolor="#CCCCCC" class="BodyText">&nbsp;</td>
          </tr>
          <tr bgcolor="#CC0000">
            <td colspan="2" class="BodyText"><font color="#FFFFFF"><strong>Origin</strong></font></td>
            <td colspan="2" class="BodyText"><font color="#FFFFFF"><strong>Destination</strong></font></td>
          </tr>
          <tr bgcolor="CCCCCC">
            <td width="20%" class="BodyText">*City</td>
            <td width="22%" class="BodyText"><input type="text" name="city1" class="FormInput"></td>
            <td width="20%" class="BodyText">*City</td>
            <td width="22%" class="BodyText"><input type="text" name="city2" class="FormInput"></td>
          </tr>
          <tr bgcolor="CCCCCC">  


Thanks
Wayne


falconseye    -- 02-02-2006 @ 6:19 PM
  i found you dont have a field named pupdate1; it's pudate1

please check your form fields to make sure they are the same in your JavaScript call

hope it helps...


awayne    -- 02-02-2006 @ 10:01 PM
  I was going through and changed it so it was pudate instead of pupdate and forgot to make the changed everywhere...  Thanks for the help!

Thanks
Wayne


EasyCFM.COM ColdFusion Forums : http://archive.easycfm.com/forums
Topic: http://archive.easycfm.com/forums/viewmessages.cfm?Forum=12&Topic=8691