java script validation help
Hi,
I have the following HTML file associated with a jquery validation. See below
What I'm trying to accomplish here is to have the form submitted when
1- The check box is checked and both arrival time and departure time are empty.
2- When check box is not checked and both arrival and departure time are not empty.
Please help
function submitMyForm() {
if(!fieldValidation())
{
return;
}
else {
fillBackDate();
document.myForm.submit();
}
}
function fieldValidation()
{
if (!($("_1_1_17_1").is(':checked')) && ($("#_1_1_13_1").val()==''))
{
alert('Please input an ARRIVAL TIME');
return false;
}
else if (!($("_1_1_17_1").is(':checked')) && ($("#_1_1_14_1").val()==''))
{
alert('Please input an DEPARTURE TIME');
return false;
}
else
{
return true;
}
}
<Fieldset>
<legend> POST </legend>
<ul>
<li>
<label class="required" for="_1_1_13_1">Arrival Time</LABEL>
<INPUT CLASS="valueEditable" TYPE="text" NAME="_1_1_13_1" TITLE="Arrival_Time" ID="_1_1_13_1" VALUE="[LL_FormTag_1_1_13_1 /]" SIZE="32" MAXLENGTH="32" ONCHANGE="markDirty();">
</LI>
<li>
<label class="required" for="_1_1_14_1">Departure Time</LABEL>
<INPUT CLASS="valueEditable" TYPE="text" NAME="_1_1_14_1" TITLE="Departure time" ID="_1_1_14_1" VALUE="[LL_FormTag_1_1_14_1 /]" SIZE="32" MAXLENGTH="32" ONCHANGE="markDirty();">
</LI>
<li>
<label for="_1_1_17_1"> Cancel</LABEL>
<INPUT TYPE="CHECKBOX" NAME="_1_1_17_1" value="1" ONCLICK="markDirty();">
</LI>
<li>
</ul>
</fieldset>
<INPUT TYPE="BUTTON" VALUE="SUBMIT " ONCLICK="submitMyForm();">