I need to submit the contents of the form when I press a key Enter, but only if the form does not have an error message. I created the following function:
$(targetFormID).submit(function (e) {
var mess = error_m(targetDiv);
if (e.keyCode == 13 && mess.length > 0) {
e.preventDefault();
e.stopPropagation();
}
if (mess.length == 0 && e.keyCode == 13) $(targetFormID).submit();
});
In this function, the messy variable receives the error message returned by the function error_m, the rest is a simple conformation of the code, but it does not work.
Need help with this!
sorin source
share