My Question derivate from this post
I would like to disable a submit button until two input are filled in with a datepicker. I have no trouble doing it with standart text input but it's not working with my datepickers. I strongly suspect it's about the datepickers id's.
First is an example of what I want to do (without datepickers). Then what I'm trying to do with datepickers.
With text input (working) :
Body :
<form method=post>
<input type="text" id='first_name'>
<input type="text" id='second_name'>
<input type="submit" value="Submit" id="submit" disabled>
JQuery :
<script>
$(':text').keyup(function() {
if($('#first_name').val() != "" && $('#second_name').val() != "") {
$('#submit').removeAttr('disabled');
} else {
$('#submit').attr('disabled', true);
}
});</script>
With the datepickers (not working) :
Head :
<script>
$(function() {
$( "#datepicker1" ).datepicker({ dateFormat: 'dd/mm/yy' , minDate: new Date(2016, 04 - 1, 21), maxDate : new Date(2016, 05 - 1, 04)});
$( "#datepicker2" ).datepicker({ dateFormat: 'dd/mm/yy' , minDate: new Date(2017, 04 - 1, 21), maxDate : new Date(2017, 05 - 1, 04)});
</script>
Body :
<form method=post>
<input type="text" id='datepicker1'>
<input type="text" id='datepicker2'>
<input type="submit" value="Submit" id="submit" disabled>
JQuery :
<script>
$(':text').keyup(function() {
if($('#datepicker1').val() != "" && $('#datepicker2').val() != "") {
$('#submit').removeAttr('disabled');
} else {
$('#submit').attr('disabled', true);
}
});</script>