I am looking to activate the submit button once both the FromDate and ToDate fields are selected.
In my scenario, all form fields must be filled out in order to enable the submit button.
$('#myform > input').on('input', function() {
var empty = false;
$('form > input, form > select').each(function() {
if ($(this).val() == '') {
empty = true;
}
});
if (empty) {
$('#register').attr('disabled', 'disabled');
} else {
$('#register').removeAttr('disabled');
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="myform">
Name
<input type="text" id="" name="name" />
<br/>
<br/>From Date
<input type="date" name="fdate" />
<br/>
<br/>To Date
<input type="date" name="fdate" />
<br/>
<br/>
<input type="submit" id="register" value="Register" disabled="disabled" />
</form>
My goal is to have the submit button enabled only when both the FromDate and ToDate fields are selected.