Fahad Khan
Fahad Khan

Reputation: 1635

onClick with CTRL button

I have an issue with the button clicking with Ctrl key. The form is being posted twice. (on the same tab and on the new tab)

I don't want to go to new tab (in order to avoid twice submission)

I tried return false;

onClick="document.form[0].submit(); return false;"

but no success.

Thanks for any help.

Here is jsFiddle

Upvotes: 2

Views: 363

Answers (2)

Fisk
Fisk

Reputation: 651

try next:

  1. replace document.form[0] by document.forms[0];
  2. add name attribute for your input tag;
  3. change your button type attribute to button

my corrected JsFiddle

Upvotes: 1

Bhojendra Rauniyar
Bhojendra Rauniyar

Reputation: 85573

Try this:

$('#submit').on('click',function(e){
  e.preventDefault();
  document.form[0].submit();
});

Upvotes: 0

Related Questions