I have two password fields on a form. I have used your demo way to change there editor to password boxes. If I validate in the controller and pass back an error message indicating they need to match the error message is not displayed. How do I correct this. I am open to preventing the submit with a little javascript validation so it never goes to the server. Please Advise.
i.Add()
.Field(f => f.Password)
.EditorTemplateHandler("setPasswordEditor")
.Label(l => l.Text("Password:"));
i.Add()
.Field(f => f.ConfirmPassword)
.EditorTemplateHandler("setConfirmPasswordEditor")
.Label(l => l.Text("Confirm Password:"));
function setPasswordEditor(container, options) {
container.append($("<input type='password' class='k-textbox k-valid' id='Password' name='Password' title='Password' required='required' autocomplete='off' aria-labelledby='Password-form-label' data-bind='value:Password' aria-describedby='Password-form-hint'>"));
}
function setConfirmPasswordEditor(container, options) {
container.append($("<input type='password' class='k-textbox k-valid' id='ConfirmPassword' name='ConfirmPassword' title='Confirm Password' required='required' autocomplete='off' aria-labelledby='Password-form-label' data-bind='value:ConfirmPassword' aria-describedby='Password-form-hint'>"));
}
if (model.Password!=model.ConfirmPassword)
{
ModelState.AddModelError("Password", "Passwords Must Match");
ModelState.AddModelError("ConfirmPassword", "Passwords Must Match");
return View("UserEditView",model);
}