attaching jquery validation to replacement element

后端 未结 1 763
南旧
南旧 2020-11-28 00:10

I have an aspnet mvc form with a dropdown list in, that I am replacing with a jquery combobox.

the original dropdownlist has a client validation set against it - usi

1条回答
  •  野性不改
    2020-11-28 00:28

    The plugin you're using hides the input and replaces it with its own html. By default, jQuery validation does not validate hidden form controls but you can override this behavior by modifying the validator

    $.validator.setDefaults({ 
        ignore: [] 
    });
    

    Note that if you have other hidden elements that you don't want validated, then you could give the element a class name

    $.validator.setDefaults({ 
        ignore: ":hidden:not('.combobox')"
    });
    

    Note: Make sure that this script is outside the $(document.ready) function.

    0 讨论(0)
提交回复
热议问题