jQuery - can I validate a disabled field?

Viewed 14748

I've got a form where the user needs to click a link, select a user via a popup window which then populates a hidden field with an ID and a display field with the username.

The display field is set to disabled="disabled" to force the user to use the popup and not type a value in the field.

I need to ensure the user selects a name. I'm using jQuery and Jorn's validation plugin.

Doing a required: true on the disabled field doesn't seem to fire off if the value is blank.

Any ideas how to solve this?

4 Answers

I used this code.

if($('#element').prop('disabled')){
   $('#element').prop('disabled', false);
   $('#element').valid();
   $('#element').prop('disabled', true);
}
Related