TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
athira k
NA
140
53.8k
How to give client side validation MVC
May 24 2017 1:40 PM
I have given validation on server side but I need validation on typing itself. It must show the error message when typing is wrong.
controller
if (!string.IsNullOrEmpty(student.FirstName))
{
string nameRegex = @"^([a-zA-Z ])+$";
Regex re = new Regex(nameRegex);
if (!re.IsMatch(student.FirstName))
{
ModelState.AddModelError("FirstName", "FirstName only be letters");
}
}
else
{
ModelState.AddModelError("FirstName", "FirstName is required");
}
I have given validation in regular expression Like this in controller part
I need to give validation for name that it should accept only letters and numbers and no special characters
model
public string FirstName { get; set; }
how can I do this ?? can anyone please help me to do this ?
Reply
Answers (
4
)
How to calculate birthday with sql database in core application
Form tag inside master page and content page