I have these:
- Bootstrap Modal
- inside the modal is a simple form
- the only input is jQuery UI Datepicker
- form is validated by FormValidation(.io)
Everything works just fine, except, for some reason when i don't select any date and the formvalidation is triggered (invalid state), the Datepicker popup is triggered.
Is this normal behaviour and what is the way to prevent it?
UPDATED
My validation and datepicker look something like this:
$("#return-modal-form").formValidation({
.
.
.
fields: {
datetimePicker: {
selector: '#return-date',
err: '#return-date-live',
validators: {
notEmpty: {
message: 'Required'
}
}
}
}
})
.find('#return-date').datepicker({
onSelect: function(date, inst) {
$('#return-modal-form').formValidation('revalidateField', 'datetimePicker');
}
});
This is much closer to examples on formvalidation site. Is it possible to set a date on a datepicker like i am calling it? I've tried many different things, but either i have some kind of error or it simply doesn't set it.
Yes, if the date field will be empty and required, then on submit the Date input field marked invalid and the calendar popup will show and it's a normal behaviour.
Here is an example on formValidation plugin site
Solution One
So either you can set a default date, if you don't want the Date Picker calendar to show Or remove the
required
condition from DatePicker field.SideNote: If you want DateField to be required then you also need to Revalidate the field when selecting new date from the datepicker
Read More about plugins compatibility.
Alternate Solution
Following Conditional Validation can do the trick