I have four date fields.

taahamushtaq
Tera Contributor

I have four date fields on my catalog form. I have four fields in two pairs i.e. Week start date & Week end date as one pair, normal start date and normal end date as second pair.
Now I want to validate, atleast one pair of date is selected before submitting the form.

9 REPLIES 9

Hello,

I want to validate from given four date fields , atleast one pair of date fields are having value.

what do you mean by validate? Do you want to check if these fields have a value, do you wan to check end date is after start, do you want ti check if the date is in past or not. 

Validate is pretty open ended and if you want right answer you have to explain the ask.

-Anurag

I want to validate if there is value in the field.

I want to check if the user has filled any of the two pair of dates field (consider field  A & field B is one pair ) (field -C & field -D  are one pair) , now i want user to enter any of the pair to be filled. If not entered then don't allow users to submit catalof form

in the on submit client script you can add something like below

if((g_form.getValue('<startDate1>') == '' && g_form.getValue('endDate1>') == '') || (g_form.getValue('<startDate2 >') == '' && g_form.getValue('endDate2 >') == ''));
 {
//alert('throw error');
return false;
}

 

Add proper field variables names in the if.

-Anurag