Submit button on the Form Action on Web ---doesn't pass the validation ---Please help

Hi All,

I have a Submit button on the Form --When I open the form on the web , I have some validations to check if the Field is empty or not , but when I clcik it bypasses the validation even if the Fioeld is empty or with certain criteria

Please help

Here is the code behind the Submit button

var f = document.forms[0];

if (f.EntryType.checked == “Business Travel” && f.ArrivalTime.value == “”)

  {

                  alert("Please enter Arrival Time in hh:mm format")

            return false;

            }

if (f.EntryType.checked == “Business Travel” && f.DepartTime.value == “”)

{

            alert("Please enter Departure Time in hh:mm format")

            return false;

}

// if (validateDate(f.EndDate, “EndDate”) == false)

// return false;

// if (validateSelect(f.HomeLocation, “HomeLocation”) == false)

// return false;

//if (validateSelect(f.DestinationLocation, “DestinationLocation”) == false)

// return false;

if (f.Duration.value == 0)

{

alert(“Duration needs to be greater than 0 , click the Calculate Button to calculate the Duration” )

	return false;

}

if (confirm(“Are you ready to submit this form now?”))

{

f.Action.value = "Submit";

	f.submit();

}

I get the alert for Duration, but I don’t get any alerts for the previous If condition.

Please help

Thanks in advance

ac ac

Subject: Submit button on the Form Action on Web —doesn’t pass the validation —Please help

What happens if you change your empty strings (“”) to the keyword null?

just a thought.

brandt

Subject: RE: Submit button on the Form Action on Web —doesn’t pass the validation —Please help

Hi Brandt,

I just forgot to mention document.forms[0].EntryType (This field Entry Type is a radio button…and wehen I select the radio button as “Business travel” and if ArrivalTime (Field is blank) then alert a message the Field Arrival Time cannot be blank

Please help, how to validate a field that is based upon radio button if selected , the otehr field cannot be blank

Thanks ,

ac ac

Subject: RE: Submit button on the Form Action on Web —doesn’t pass the validation —Please help

You might find this function helpful. Checking a radio button value then becomes:

if (atGetField(“FieldName”)[0] == “Desired Value”)

Subject: RE: Submit button on the Form Action on Web —doesn’t pass the validation —Please help

Stan, I’m not sure about where to place the JavaScipt. The function goes in the JS Header right? But where does the if call go? Does it go in the field?

if(atGetField(“FieldName”)[0] == “Desired Value”)