validation - ModelState.IsValid does it work with ajax call ? -
the model :
public class changepasswordmodel { //user profile key public string username { get; set; } [required(errormessage = " please come in current password ")] public string oldpassword { get; set; } [required(errormessage = " please come in new password ")] [stringlength(20, minimumlength = 6, errormessage = "the {0} must @ to the lowest degree {2} , no longer {1} characters long.")] public string newpassword { get; set; } [required(errormessage = " please re-enter new password ")] [mustbevalidator(mustbevalidator.condition.equalto, "newpassword", errormessage = "please, confirm password")] public string renewpassword { get; set; } }
ajax phone call security apicontroller :
[system.web.mvc.httppost] public actionresult changepassword(changepasswordmodel change) { if (!modelstate.isvalid) {
the problem is, when "newpassword" diff "renewpassword" modelstate.isvalid = true
i don't know mustbevalidator
may seek using standard attribute in asp.net mvc 3:
[required(errormessage = " please re-enter new password ")] [compare("newpassword", errormessage = "please, confirm password")] public string renewpassword { get; set; }
ajax validation asp.net-mvc-4
No comments:
Post a Comment