Validating required selection in DropDownList

前端 未结 2 1794
萌比男神i
萌比男神i 2020-12-06 04:59

My view model defines property which has to be displayed as combo box. Property definition is:

[Required]
public int Processor { get; set; }
<
2条回答
  •  感情败类
    2020-12-06 05:28

    One possible issue is that jQuery Validate does run any rules if the value of an element is empty.

    You can get around this by retriggering the validation when the user loses focus:

    // select statements not firing null validation automatically
    $("select").blur(function () { $(this).valid() });
    

提交回复
热议问题