Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE10 - Must click 2 times to submit form after choosing a file to upload

In a form I have a file input skinned with jquery and css and a submit button.

<form action="#" method="POST">
  <input style="width:150px" type="hidden" name="MAX_FILE_SIZE" value="40000"/>
  <div class="l-input-file">
    <input style="margin-bottom: 0px" type="file" id="myInput" name="myInput" size="16" />
  </div>
  <div><button type="submit" class="btn-black">Continuer</button></div>
</form>

http://jsfiddle.net/CsL9t/

The matter here appear only on IE10: After a file has been selected the submit button must be clicked 2 times to be able to submit the form.

I tried forcing the focus on the button when the file input change but it doesn't help.

I tried triggering the click using jQuery,

jQuery('#myInput').parents('form').find("button[type='submit']").click();

but I received 2 times the message 'access denied' before submitting the third time.

Any input or advice will be strongly appreciated. Thanks

like image 607
svassr Avatar asked Sep 04 '13 22:09

svassr


People also ask

How to automatically submit form after uploader input field is changed?

We have used the jQuery change method to detect the change in uploader input field by the id of the field and then submit the form automatically using JavaScript submit method. If you test it on your browser, then you will see the same thing is happening in here also. it will submit the form instantly after you select a file.

How to submit the form automatically when you select a file?

This method helps to detect the changes of the file input field. After that, we have used the submit () method to submit the form automatically. If you test it on your browser then you will see that the form submitted automatically when you select a file. This task also can be done by using jQuery. Below is the jQuery code that will do that easily:

How to disable form submission for second time?

Option 1: Stop form submission at client side event of button click, when it happens for second time Option 2: When you click Submit button, disable it and call the PostBack event method directly. Please note that PostBack event method should be called explicity as disabling the button will not post the data to the server.

How to prevent multiple submissions of a form in WordPress?

On click of button, which is used for submitting form, we are calling the function preventMultipleSubmissions. This function checks whether the variable isSubmitted is false – if it is false, it will change the value to true (and optionally change the text of button) and submits the form.


1 Answers

$input.trigger('click'); is what causes the access denied error.
Triggering a click event on a file input taints a file input in IE preventing(to some extent) you from submitting the form or using it with a FormData object.

See also getting access is denied error on IE8

like image 141
Musa Avatar answered Nov 15 '22 10:11

Musa