Disable form submission on pressing enter because i am using Ajax functionality
How are you calling your Ajax function? It should be inside the submit
event handler of the form. And then if you have the event handler return false
it won't submit normally:
<form onsubmit="doAjaxSubmit(); return false;"> ...</form>
You can detect which key is pressed using the .keypress()
method. From this you should be able to return false;
for form submit and do your ajax stuff on the back of it in an if
statement:
You can have your form's onSubmit
return true
if all the fields have values, or false
if they don't.