jquery - How to validate data requiring a look "up the object graph"? -
i'm hoping there's easy way via asp.net mvc built-in support validation attributes, haven't been able see far.
notes:
we using:
- mvc3
- jquery unobtrusive validation
- twitter bootstrap "wizard" tabs
the wizard works via ajax - not submitting form each step of way.
here code inherited (slightly changed protect innocent):
here basic view model(s) (note not public variables - auto-properties condensed space):
class transactionviewmodel { public reasonviewmodel reason; /* in tab, user selects reasons change */ public customerviewmodel customer; /* details customer user can edit */ public surveyviewmodel survey; /* survey wizard experience user can fill out */ /* (also, "the wizard experience", new band name, call it.) */ }
here view inherited
<div class="tab-pane" id="reason"> @html.editorfor(m => m.reason, "reasonviewmodel") </div> <div class="tab-pane" id="reason"> @html.editorfor(m => m.customer, "customerviewmodel") </div> <div class="tab-pane" id="reason"> @html.editorfor(m => m.survey, "surveyviewmodel") </div>
and here problem:
**we need implement validation such when user enters reason of "add customer", customer.dateofbirth property cannot set date in future. purposes of example, want validation occur on particular reason - other reasons leave alone. **
my question is: if put validator on customer.dateofbirth, how can move 'up chain' transaction.reason in order find out if need reject date or not?
i suppose wish this:
class transactionviewmodel { /* ... */ [addmembercanthavefuturebirthdate] public reasonviewmodel reason; /* in tab, user selects reasons change */ /* ... */ }
but can't seem validation work @ level.
has run type of thing before? if so, how did solve it?
Comments
Post a Comment