How can I disable client validation for some fields in asp.net MVC.
I have not defined any validation for Order property but it show “The Order field is required” in client. I want to disable client validation for Order.
public class Product
{
...
[Required(ErrorMessage = "Name Is Required")]
public String Name { get; set; }
public int Order { get; set; }
...
}
intisnon nullabletype. Is cannot be assigned empty value, so metadata provider automatically makes it required. If your business doesn’t needOrderfield filled in forProductclass, make it nullable type –Nullable<int> Order. This way it won’t be made required unless you explicitly make it.Well, there is another way – using some scripts on client side. But this will disable validation only on client side, after post to server, the error message will still appear unless you make it
nullable. Assuming you use default jquery validation plugin for asp.net mvc 3, you can use remove rules function