I am using ValidationSummary
to show errors after submit login action on my login page.
There are two different errors to show.
1) Username and password invalid
or
2) You are not allowed to access this feature
The thing is that I want to change the text of the ValidationSummary
. I don't want to add errors as bullet points (this is done adding errors to ModelState
using ModelState.AddModelError
).
How can I achieve this? Change the error message of the ValidationSummary
?
Thanks!
The simplest solution is that you can return message in json in your post method. and display that message in span instead of validation summary.
For example
return Json(new object[] { false, "Invalid user name or password" },
JsonRequestBehavior.AllowGet);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.