How to Set Range for model with out required validation

 in my modelclass i set like this

[Range(typeof(int), "0", "99", ErrorMessage = "Value must be between 0 and 100")]
public int ReviewPercentage { get; set; }

and in view

@Html.TextBoxFor(x=>x.ReviewPercentage )


when submitting the range field is working fine. but with out leaving empty the text box it’s firing the error message like the field is required

but i want to validate when ever the value is entered in the textbox then if it’s empty i dont want to validate. so how can i do it in my model 

public int? ReviewPercentage { get; set; }

Leave a Reply