I'm trying to set up code so that I can show or hide the submit button based on any type of field, single line, radio button, dropdown, checkbox, signature field. I've gotten the code to work for all but the dropdown field and the date field.
Here is what is working:
$(document).ready(function () {
var $submit = $('.Submit');
var $single = $('#Field1');
var $radio = $('#Field2');
// bind to radio button
$($radio).click(function () {
if($('input[value="RB1"]').is(':checked'))
{
$submit.show();
}
else
{
$submit.hide();
}
});
//bind single line
$($single).on("change", function() {
if ($(this).val() !== " "){
$submit.show();
} else {
$submit.hide();
}
});
//bind to signature
$('.Sign_Sig').click(function () {
$('.Submit').show(); //show the submit button after signing
});
$(document).on('click','.form-sig-remove',function(){
$('.Submit').hide(); //hide the submit button if the signature is removed
});
});
but when I try to bind to either a date or dropdown field it doesn't work... Here is my date code:
Date field is "q5"
//bind to date
$('#q5').on ("change", function(){
if($(this).val() !== ""){
$submit.show();
} else {
$submit.hide();
}
});
And my dropdown field is Field4 or "q4"
Here is my code for that:
//bind event handler to the dropdown field
$('#Field4').change(function() {
//if the user selects what we want, show the submit button
if ('$Field4 selected').val() === "Dropdown 1"){
$submit.show();
}
//if not, hide it
else {
$submit.hide();
}
});
When I put either of these two sections of code in my JavaScript, the submit button always is shown.
Help?