You are viewing limited content. For full access, please sign in.

Question

Question

Hide the submit button if criteria is not met

asked on April 11

I was able to piece together the following code. 

In addition to setting Focus values (each fillable field value is scanned), it checks the values of #q2, #q3, #q4 to see if #q3 and #q4 matches #q2.  If they all do NOT match then #q5 (html field) is shown.  I am trying to also add the code to hide the submit button along with showing the HTML alert field - #q5.

Thus far my attempts have failed.

Any help would be appreciated.

$(document).ready(function() {
    $('#q1 input').focus(); // Trigger focus on the input field inside #q1

    $('#q1 input').keyup(function() {
        setTimeout(function() {
            if ($('#q1 input').val().length > 0) {
                $('#q3 input').focus();
            }
        }, 500); // Wait for 0.5 seconds before moving focus
    });

    $('#q3 input').keyup(function() {
        setTimeout(function() {
            if ($('#q3 input').val().length > 0) {
                $('#q4 input').focus();
            }
        }, 500); // Wait for 0.5 seconds before moving focus
    });

    $("#q5").hide();
    $("#q2 input, #q3 input, #q4 input").change(function(){
        if ($("#q2 input").val() != $("#q3 input").val() && $("#q3 input").val() != '') {
            $("#q5").show();
                 }
        else if ($("#q2 input").val() != $("#q4 input").val() && $("#q4 input").val() != '') {
            $("#q5").show();
        }
        else {
            $("#q5").hide();
        }
    });
});

0 0

Replies

replied on April 11 Show version history

If I'm understanding correctly - you have it working to show/hide #q5 - and you just want to additionally show/hide the submit button.  Is that correct?

If so, then lines 23, 26, and 29, could be appended like this: 

//line 23:
$("#q5").show();
$(".Submit").hide();

//line 26:
$("#q5").show();
$(".Submit").hide();

//line 29:
$("#q5").hide();
$(".Submit").show();

 

This works because the Submit button has a class named Submit.  The other buttons have similar class names (Approve and Decline for example).  Note that if you are a newer version of forms, these class names can be edited (along with adding additional buttons) when you set-up your form tasks.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.