I made a script that sends information from the input to a script whenever a keyup happens. The problem is that it sends a request whenever any key is pressed(obviously). This means that some requests, when for instance arrow keys are pressed, are done for nothing. Is there a way to remove such requests or it doesn't matter if they happen?
$('input[name="rusername"]').on("focus keyup", function() {
// if ($(this).val() === '') $('#rusererr').html('Enter your desired username; between 8 and 32 characters');
var username = $(this).val();
$.post("register.php", {
rusername: username
}, function(stuff) {
//daca nu sunt erori
if (stuff==='1') alert(stuff);
else alert(stuff);
});
});