i have form number of fields.
some of them userid, userfirstname, userlastname.
when user inputs incorrect userid value near userid field page must show error message , add error validationsummary(this standart behavior asp.net mvc unobtrusive validation). if userid correct page must remove errors , autopopulate userfirstname , userlastname(this not standart behavior)
how can implement this?
here come mind:
remote validation attribute
it has bad customization in case. that's why decide don't use it.
add special method jquery validation plugin ( example
jquery.validator.addmethod("useridvalidation", function(value, element) { //some logic return something; }, "please specify correct userid"); )
and put there logic validation , autopopulate other fields. in case mix validation , other stuff.
3 . add special method jquery validation plugin validation , add special handler input change event autopopulate.
in case need send 2 ajax requests server 1 thing. , ofcourse not too. right way? confused.
have thought using partial view display userfirstname , userlastname?
you can fire ajax request sends userid, , returns partial view of name fields. within controller being called, can validate incoming userid, , grab name details in 1 query. if thevalidation fails, can return partial view empty fields.
Comments
Post a Comment