View Single Post
10-08-2007, 02:26 PM
#2
Steven Fergus is offline Steven Fergus
Status: Hey, I'm Steven
Join date: Feb 2007
Location:
Expertise:
Software:
 
Posts: 1,212
iTrader: 3 / 100%
 

Steven Fergus is on a distinguished road

  Old

My first question doesn't matter so much now. I've found a bigger problem with the code I'm using.

Here is the code I was trying to use to validate my form:

Code:
function validateForm()
      {
          with (document.order) {
          
          
          if ((name.value == "")&&(email.value == "")&&(subject.value == "")&&(Price_list.value == "")) {
              alert("Please enter your Surname \n Please enter a valid e-mail address \n Please enter a Subject \n Please choose a price option");
              return false;
          }
      
          if (name.value == "") {
              alert("Please enter your name");
              return false;
          }
   
           if (email.value == "") {
              alert("Please enter your email");
              return false;
          }
          
          if (subject.value == "") {
              alert("Please enter a Subject");
              return false;
          }
          
          if (Price_list.value == "") {
              alert("Please select a price option");
              return false;
          }
            }
        return true;
 
      }
But that wont work at all.



If I leave all the fields blank, I should - if the && statement worked - get a messege saying that all the fields need to be filled in. But, if I only fill in field A, it wont tell me to fill in B,C and D. It will only prompt me to fill in one of those three.

I'm sorry for going on, but it was hard to explain what I was meaning. I guess I need to look into a whole different method for doing this.