jquery-form/form

ajaxSubmit using option iframe:true removes disabled attribute from all form elements

smoothlikejazz opened this issue · 2 comments

Description:

We have a dynamic form that's shown to users, in which some fields are disabled, within this same form we have a file upload element and were using the ajaxSubmit of a file using a target iframe with property iframe:true.

I've found out here the library is removing the disabled property yet not placing it back. Line 248 in jquery-form version 2.96

if (a) {
	// ensure that every serialized input is still enabled
	for (i = 0; i < elements.length; i++) {
		el = $(elements[i]);
		if (hasProp) {
			el.prop('disabled', false);
		} else {
			el.removeAttr('disabled');
		}
	}
}

So the issue now is users are able to update the disabled fields and as a side affect these form elements are submitted when a user completes the dynamic form.

Expected Behavior:

From the code the disabled properties are removed for a reason it looks like, but the expectation should be that jquery-form will revert/update the form to its original state with the disabled attributes re-enabled if it was previously set

Actual behavior:

jquery-form is removing all disabled properties from the form elements

Versions:

LoadJSON:
jQuery: // v1.11.3
Browsers: // Chrome
jquery-form version: //version: 2.96 (16-FEB-2012)

Steps to reproduce:

  1. Create a form with 2 elements, on file upload, and the other a simple select box that is disabled
  2. Use the method of ajax submitting data to an iframe,
  3. Observe after selecting the file for upload, that the disabled element is no longer disabled

Are you still experiencing this issue when using the latest version, 4.2.2?

Instructions for Reporting a Bug
Would you please create an example of the error on JSFiddle or CodePen so that others can reproduce the issue you're seeing?

Hi Kevin, thanks for the reply, So using the latest version 4.2.2 works like a charm :).
Unfortunately I have found out our company has modified the library a bit since version 2.96. So i've been instructed to merge the specific change thats working in 4.2.2 regarding the iframe and disabled elements to our library.

I'll mark this as closed as its a non-issue with the latest version. Thanks again Kevin