View Single Post
  #1 (permalink)  
Old April 25th, 2006, 07:15 PM
bleutiger bleutiger is offline
Authorized User
 
Join Date: Jan 2005
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default Validate only if enabled

Validation only if item is eneabled

--------------------------------------------------------------------------------

Need help everyone...

I have a form that is validated by javascript, pretty standard no errors works gret.

I have a file form element that is only enabled, if, one or two items from a select box are chosen...this also works.

The part I am having trouble with is that when the file form element is enabled I want to make sure that it is not left blank.

here is my code so far...


Code:
function validate1() {

var theMessage = "All fields in this form are required. \n"  
theMessage = theMessage + "\n Please complete the following:" 
theMessage = theMessage + "\n-----------------------------------\n";

var noErrors = theMessage


if (document.theForm.ImageUpload.enabled==true) {

     //Make sure a text box is filled
    if (document.theForm.ImageUpload.value=="") {
        theMessage = theMessage + "\n --> Please choose a graphic to upload.";
    } else {

}

// If no errors, submit the form
if (theMessage == noErrors) {
return true;

} else {

// If errors were found, show alert message
alert(theMessage);
return false;
}
}



There are no errors but no validation either...I need help!


Reply With Quote