[ACCEPTED]-How to submit form onkeyup action-jquery-events

Accepted answer
Score: 14

This code will submit your form on keyup

$('#element').bind('keyup', function() { 
    $('#form').delay(200).submit();
});

In 5 this code you intercept the form submit 4 and change it with an ajax submit

$("#form").submit(function (event) {
    event.preventDefault();
    $.ajax({
        type: "post",
        dataType: "html",
        url: '/url/toSubmit/to',
        data: $("#form").serialize(),,
        success: function (response) {
            //write here any code needed for handling success         }
    });
});

To use 3 the delay function you should use jQuery 2 1.4. The parameter passed to delay is in 1 milliseconds.

Score: 2

From this jQuery forum thread:

$('#element').bind('keyup', function() { $('#form').submit(); } );

0

Score: 1

This is my solution:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-br" lang="pt-br">
<head><title>Submit after typing finished</title>
<script language="javascript" type="text/javascript">
function DelayedSubmission() {
    var date = new Date();
    initial_time = date.getTime();
    if (typeof setInverval_Variable == 'undefined') {
            setInverval_Variable = setInterval(DelayedSubmission_Check, 50);
    } 
}
function DelayedSubmission_Check() {
    var date = new Date();
    check_time = date.getTime();
    var limit_ms=check_time-initial_time;
    if (limit_ms > 800) { //Change value in milliseconds
        alert("insert your function"); //Insert your function
        clearInterval(setInverval_Variable);
        delete setInverval_Variable;
    }
}

</script>
</head>
<body>

<input type="search" onkeyup="DelayedSubmission()" id="field_id" style="WIDTH: 100px; HEIGHT: 25px;" />

</body>
</html>

0

More Related questions