jquery-validation / jquery-validation

jQuery Validation Plugin library sources

Home Page:https://jqueryvalidation.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Radio buttons validated even if checked value is disabled

king2 opened this issue · comments

I think current behavior for validating radio-buttons is wrong.

  1. create two radio-buttons with same name
  2. select one of them
  3. disable it
  4. try to validate a form

Expected result: form not valid due to selection of disabled element.
Current result: form is valid.
Problem is: not checked :disabled attribute for radio buttons.

I think that string:
this.findByName( element.name ).filter( ":checked" )
should be changed to this:
this.findByName( element.name ).filter( ":checked" ).not( ":disabled" )
in two places inside source file.

I have tested this change and now everything works in a right way.
I think this change should be applied into source code of this repo.

Wouldn't it just be best to use your own validator?

I like this validator and just pointed to its wrong (as I believe) behavior (and even how to improve it).

I cannot understand why validator should use values from disabled radio-buttons, when it not uses such values in case of text inputs.

Is there a reason you can't uncheck the radio button at the same time it's disabled? That would communicate to users more clearly that they can't select that option and need to pick another.

This issue/proposal has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automatically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and one of the maintainers will (try!) to follow up.
Thank you for contributing :)