Jquery .submit() + Disable Input File
I have a form that is using .change() and .submit() to upload a photo as soon as a user selects one. I'm now trying to implement a disabled on the input file after the submit() has
Solution 1:
You need to prevent the form from submitting again if the file input is disabled. the second eventListener will do that for you.
$('input#file').change(function() {
$('form#joinPhotoUploadForm').submit();
$('input#file').prop('disabled', true); // Disable to Prevent Multiple Files Uploads
});
$("#joinPhotoUploadForm").submit(function(e) {
if ($(this).find("#file").is(":disabled")) {
e.preventDefault();
}
});
Solution 2:
I like doing like this: $('#myform').trigger( 'reset' );
Post a Comment for "Jquery .submit() + Disable Input File"