I have a form and i need to submit the form as soon as some change has been made to one of the fields in the form without having the user to click update or submit button.
I am familiar with AJAX and I can get the form to submit via AJAX using a button, but i now need to change this to submiting a form as soon as the user types something in one of the fields
At present I am putting the .keydown()
on each input field although it works but this is making the script really long and i was wondering if there is a better way to handle it. This is what I am doing to individual fields to detect change
if ($("#some_field").length) {
var timer = null;
$('#some_field').keydown(function () {
clearTimeout(timer);
timer = setTimeout(update, 1000)
});
function update(){
$.ajax({
...
...
...
}
});
}
}
I will really appreciate any assistance here.