views:

113

answers:

1

hey all,

i'm using bassistance jquery plugin validation and i have 2 textboxes for a start and end date. is there a way to setup a rule to say if either one is specified then require both fields, but the user can choose to leave both blank and that's ok?

thanks, rodchar

A: 

You can specify an expression to indicate whether a form field is required (documentation).

Lets say your form fields are called tbStartDate and tbEndDate, then your validation rules would be (untested):

$('#myForm').validate({
    rules:{
        tbStartDate: {required:'tbEndDate:filled'},
        tbEndDate: {required:'tbStartDate:filled'}
    }
});
Ravish
Thanks for the help,rod.
rod