Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
4
Reply
How to give client side validation MVC
athira k
May 24 2017 1:40 PM
298
Reply
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 ?
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
4
)
Next Recommended Forum
How to calculate birthday with sql database in core application
Form tag inside master page and content page