0

it's my validation for chosen enabled select:

SellerDropDownList: {
    required: {
        depends: function (element) {
            return $("#SellerDropDownList").val() == "-1";
        }
    }
}

Default value is -1, but it does not work and when I click submit button; It passes validation while chosen selected value is -1.

JSFiddle: http://jsfiddle.net/maysamsh/rLQDK/18/

Maysam
  • 7,246
  • 13
  • 68
  • 106

1 Answers1

0

Reading the documentation, required does not work the way you are trying to use it.

One option I found to work is min:

    SellerDropDownList: {
        min: 0
    },

Demo

Another possible way is to define your own rule ("not equal") described under this question.

Community
  • 1
  • 1
kapa
  • 77,694
  • 21
  • 158
  • 175
  • It only works when the plugin is not applied. http://jsfiddle.net/maysamsh/rLQDK/25/ does not work. – Maysam Mar 28 '14 at 11:06
  • @Maysam See http://stackoverflow.com/questions/11232310/how-can-i-use-jquery-validation-with-the-chosen-plugin – kapa Mar 28 '14 at 11:08
  • I have multiple chosens; "not equal" does not work too. – Maysam Mar 28 '14 at 11:36
  • @Maysam See the second answer, that will enable hidden selects to be validated: http://jsfiddle.net/rLQDK/31/ – kapa Mar 28 '14 at 11:41