0

In my project I use jquery validate plugin for validate my form. In this form for the select elements I use select2 plugin. Now I tried to validate a disabled select2 field but with no success.

HTML

<select name="number" disabled>
   <option value="1">1</option>
   <option value="2">2</option>
</select>

JS

$('select').select2({
    allowClear: true
});

$("#form").validate({
    ignore: '',
    rules: {
        number: { required: true }
    }
});

How would I do that? thanks

Sparky
  • 98,165
  • 25
  • 199
  • 285
Paolo Rossi
  • 2,490
  • 9
  • 43
  • 70
  • If you disable a field, the value won't be sent when the form is submitted. If the value won't be sent, there is no need to validate the field. Why are you disabling the field? – Kevin Brown-Silva Apr 15 '15 at 14:16
  • I enable/disabled the field dinamically. I'd like to alert (validate error) only if the field is disabled because it is required in the form – Paolo Rossi Apr 15 '15 at 14:52
  • You need an ` – Sparky Apr 15 '15 at 15:00

0 Answers0