MuriloKunze
MuriloKunze

Reputation: 15593

Remove client-side validation

Assuming I have a specific problem which I need to remove some dataannotations's required attributes, how can I do this?

I know about view-model but I don't want to use it for some reasons.

Upvotes: 2

Views: 4888

Answers (2)

Nadeem Khedr
Nadeem Khedr

Reputation: 5313

this will disable the validations on certain elements based on a selector

var validationSettings = $.data($('#formToValidateId').get(0), 'validator').settings;  
validationSettings.ignore = '.ignore';  

check this blog for more info

Upvotes: 1

TRR
TRR

Reputation: 1643

If you just want to disable validation for a single field in client side then you can override the validation attributes as follows:

@Html.TexBoxFor(model => model.SomeValue,                  
new Dictionary<string, object> { { "data-val", false }}) 

Here is the source for more answers

Upvotes: 6

Related Questions