Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Web Technology by (20.3k points)

I have a bog-standard login form - an email text field, a password field and a submit button on an AIR project that's using HTML/jQuery. When I hit Enter on the form, the entire form's contents vanish, but the form isn't submitted. Does anyone know if this is a Webkit issue (Adobe AIR uses Webkit for HTML), or if I've bunged things up?

I tried:

$('.input').keypress(function (e) {

  if (e.which == 13) {

    $('form#login').submit();

  }

});

But that neither stopped the clearing behavior or submitted the form. There's no action associated with the form - could that be the issue? Can I put a javascript function in the action?

1 Answer

0 votes
by (40.7k points)

Try using the code given below:

$('.input').keypress(function (e) {

  if (e.which == 13) {

    $('form#login').submit();

    return false;    //<---- Add this line

  }

});

Note: Essentially, "return false" is the same as calling e.preventDefault and e.stopPropagation().

Related questions

0 votes
1 answer
asked Sep 2, 2019 in Web Technology by Tech4ever (20.3k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...