Hi hnmahant,
Check this example. Now please take its reference and correct your code.
To validate without JavaScript use RegularExpression to the Model properties.
For more details refer below article.
Model
public class AccountViewModel
{
[Required(ErrorMessage = "Email is required.")]
[RegularExpression(@"^\w+([-+.']\w+)*@123g.com$", ErrorMessage = "Invalid Email.")]
public string Email { get; set; }
}
Controller
public class HomeController : Controller
{
// GET: /Home/
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(AccountViewModel account)
{
if (ModelState.IsValid)
{
}
return View();
}
}
View
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<_210357_Email_Model_Validation.Models.AccountViewModel>" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Index</title>
<style type="text/css">
.error
{
color: red;
}
</style>
</head>
<body>
<% using (Html.BeginForm("Index", "Home", FormMethod.Post))
{%>
<%= Html.LabelFor(m => m.Email)%>
<%= Html.TextBoxFor(m=>m.Email) %>
<%= Html.ValidationMessageFor(m => m.Email, "", new { @class = "error" })%>
<br />
<input type="submit" value="Submit" />
<% } %>
</body>
</html>
Screenshot
