ASP.NET MVC optional field being treated as required

前端 未结 6 2013
被撕碎了的回忆
被撕碎了的回忆 2020-12-15 02:57

I have this field that for some reason when I click on submit, gets a validation message that the field is required.

[DisplayName(\"Total Budget:\")]
public          


        
6条回答
  •  [愿得一人]
    2020-12-15 03:41

    You have to add the following line in the application_start (global.asax)

    DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
    

    Source: Unrequired property keeps getting data-val-required attribute

提交回复
热议问题