1

Following my code:

<form action="test.php"> <input type="text" onkeyup="if(event.keyCode==13) console.log('something');"/> <input type="submit"/> </form> 

How to disable submit of form with ENTER key and run correctly the onkeyup with pure javascript?

2
  • if(event.keyCode==13) console.log('something'); return false; Commented Nov 18, 2013 at 9:17
  • It's works inline, but not if onkeyup calls a function... jsfiddle.net/wrhSy Commented Nov 18, 2013 at 9:28

1 Answer 1

1

return false will prevent from submitting

if( event.keyCode== 13 ) { console.log('something'); return false; } 
Sign up to request clarification or add additional context in comments.

2 Comments

It's works inline, but not if onkeyup calls a function... jsfiddle.net/wrhSy
@user2992868 check this fiddle jsfiddle.net/wrhSy/2 Also take a look at this question

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.