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,913
  • 8
  • 46
  • 50
Abhishek
  • 4,190
  • 11
  • 39
  • 52

1 Answers1

4

try this,

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