1

I have this code :

$('#myinput').keyup(function (e) {
    if (e.keyCode === 13)
        alert('test, do not submit my form plesae !');
});

Problem is, 'myinput' is inside a form. When i press ENTER on this input, i want to only show the alert message, but my form is being submitted. How to avoid it ?

I tried this :

$('#myinput').keyup(function (e) {
    if (e.keyCode === 13)
        e.preventDefault();
        e.stopPropagation();
        alert('test, do not submit my form plesae !');
        return false;
});

But no lucky, the form is still being submitted.

Thanks !

delphirules
  • 6,443
  • 17
  • 59
  • 108

0 Answers0