ASP.NET MVC - Choose which validation annotations to use -


i have model properties this:

public class yourdetails {    [required(errormessage = "code required")]   [stringlength(10, errormessage = "code length wrong", minimumlength = 2)]   [range(0, int.maxvalue, errormessage = "please enter value bigger {1}")]   public int code { get; set; }  } 

the ui validation setup usual out of box way unobtrusive js validation plugin.

the issue: have 2 navigation actions, , next. next fine, validation fires when things wrong, , when things right i.e. .isvalid() returns true, data passed db service etc etc.

however when press 'back' have requirement validate form/viewmodel differently prior saving. i.e. make sure code positive integer, don't bother required or stringlength validation.

so want validate on next partially on back. possible?

when i've done similar in past easiest way found use fluent validation http://fluentvalidation.codeplex.com/wikipage?title=mvc. can pass parameters validator , switch different rule sets.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -