Hello,
I need some help. I have a input[type=text]
field that I have triggers on it, a .change
trigger and a .keypress
.
However, in .change
I call a field validation function and in .keypress
I check if the user pressed ENTER
to save the value of that field to the database.
So when the user types some value in this field and this field does not agree, the .change
function points the problem, but even then the .keypress
is triggered and saves the line with the wrong value.
Is there any way I do not need to call validation in .keypress
too?
Example:
$("campo").change(function(e){
valida_campo(this);
}).keypress(function(e){
if(e.which == 13) {
salva_campo(this);
}
});