Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery to disable form elements

Scenario is that I have written a function for auto refresh on form element and I want onclick event on login button to disable the auto refresh function.

I'm not able to get disable the autorefresh and the page still refreshes.

My code is:

$('#form').ready(function () { //Increment the idle time counter every minute.
    var idleInterval = setInterval("timerIncrement()", 15000); // 1 minute

    //Zero the idle timer on mouse movement.
    $(this).mousemove(function (e) {
        idleTime = 0;
    });
    $(this).keypress(function (e){
        idleTime = 0;
    });
});

function timerIncrement() {
    idleTime = idleTime + 1;
    if (idleTime > 2) { // 20 minutes
        window.location.reload();
    }
}

$('#login').ready(function () {

    alert("working promptly");
    //Zero the idle timer on mouse movement.
    $(this).click(function (e) {
        alert("Hi In click !");
        $('#form').attr("disabled","true"); 
    });


});
like image 946
anu Avatar asked Nov 13 '22 11:11

anu


1 Answers

I guess you are needing to clear the interval timer:

$(this).click(function (e) {
    alert("Hi In click !");
    $('#form').attr("disabled","true"); 
    clearInterval(idleInterval);
});
like image 97
falsarella Avatar answered Nov 16 '22 03:11

falsarella