Click here to Skip to main content
15,895,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need to add following validations on upload image control(@Html.TextBoxFor(model => model.image, new { type = "file", accept = "image/*" })):

*image type,
*image size

But I do not want to add require field validator on this control.
I want that when a user upload a image then it should be validate for size and type and when user not upload image then it should not be validate and other records could save.

Please suggest.

Thank you,

Regards,
Ashish
Posted

1 solution

You can remove the [Required] attribute from the model itself for the Upload image property.
Thanks
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900