0

How do I trigger a function while also preventing a HTML form from refreshing the page when a user hits the 'enter' key while an input element is selected?

==

I understand that <form onsubmit="return false;"> will prevent the page from reloading. But how do I also get it to trigger another function, say add();...?

George Kagan
  • 5,543
  • 8
  • 45
  • 49
Abhishek
  • 4,020
  • 11
  • 38
  • 51

1 Answers1

4

try this,

<form onsubmit="your_function(); return false;">
Sark
  • 4,242
  • 5
  • 24
  • 25