jquery click executes the function only once

I have a form with a button whose id is calbtn. The form has two input fields whose ids are input1 and input2.

I want to check if the inputs are empty after I click callbtn. If the inputs are empty, then display the alert box (whose id is failurebox) else submit the form.
But this function is executed only once during its first time. When I click again callbtn does not execute the check function. If I leave either of my input1 or input2 empty for second time.

Please help me solve this problem. I am new to using jQuery. Please correct my below code.

$(document).ready(function() {
    $("#calbtn").on('click', function() {
        if ($("#input1").val() == "" || $("#input2").val() == "")
            $("#failurebox").show();
    });// end of click function 
});


Source: php

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.