Disable Form Submission via Enter Key
Disable Form Submission via Enter Key
Afternoon all.
A real quicky after an hour of stumbling around :)
I have attempted to disable the default behaviour of the Enter key submitting the Editor form by a couple of methods:
1) Via the preSubmit event (this simply stops validation too so no use)
2) Via a delegated on keypress event against the form - this however doesnt stop the form submitting.
I have used the event to provide a .preventDefault on the form - which I suspect may not be the way to go.
I;d add that I am using the on event which allows for future creation of the modal (and is tested to establish that the keypress is picked up).
Is there a blindingly obvious way that I have missed?
$("body").on("keydown",$("form.form-horizontal"), function (e) {
if (e.keyCode == 13) {
e.preventDefault();
console.log(e);
return false;
}
});
Oo
This question has an accepted answers - jump to answer
Answers
The
submitOnReturn
option of theform-options
object can be used to disable Editor's submit on return behaviour. Full details.Allan
Hi Allan
Thanks for that:
I have this:
Which now triggers an impressive javascript error, to quantify my thinking here - because i don't have a form id, I'm capturing future enter key presses and then telling editor to ignore them, would that be the thinking or have I got it all about face?
Are you using the TableTools buttons for Editor rather than calling
edit()
yourself? If so use theformOptions.main
option and setsubmitOnReturn
to false there.Allan
Hi Allan
I found out what I was doing wrong. Taking your advice I dropped the 'submitOnReturn' option into the editor setup and then went and tweaked the javascript to remove the 'friendly' text field.
Works A1 now thank you!