asp.net mvc 3 - Required Validation Error Message is not getting displayed in jquery popup modal form -


I used the ComponentModel.DataAnnotations attribute for the verification code [Required] attribute. Although the form is not appearing in, regular expans verification and range validation are working fine.

In one of my fields, I have used both [essential] and [regular expression] when I input incorrect input in the text box, then the RegualExpression verification message appears and after deleting the input, Only required verification message Otherwise, the required verification message does not appear.

Here's my code:

- Model class

  public class email {[required (error message) = "email address is required!" )] [Regular expression ("^ ([a-zA-Z0- 9_ \\ - \\.] +) @ ((\ \ [[0- 9] {1,3} \ \ [0-9] ] {1,3} \\. [0- 9] {1,3} \\.) | (([A-zA-Z0-9 \\ -] + \\.) +)) ([A- ZA-Z] {2,4} | [0- 9] {1,3}) (\\]?) $ ", Error message =" invalid email address. ")] {Receive public virtual string email address; Set; } [Required (AllowEmptyStrings = false, ErrorMessage = "First name is required")] Public Virtual String Firstname {get; Set; } Public Virtual String MiddleName {get; Set; } [Required (error message = "Last name is required!")] Public Virtual String LastName {get; Set; } Public virtual string status {received; Set; }}    
  @ {Html.EnableClientValidation ();}  & Lt; Td width = "62%" & gt; & Lt; Div class = "editor-field" & gt; @ Html.EditorFor (model => model first name) @html. Validation message (model = & gt; model first name) & lt; / Div & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td width = "38%" & gt; Middle name: & lt; / Td> & Lt; Td width = "62%" & gt; & Lt; Div class = "editor-field" & gt; @ Html.EditorFor (model = & gt; model.MiddleName) @ html.ValidationMessageFor (model => model.MiddleName) & lt; / Div & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td width = "38%" & gt; Last name: & lt; / Td> & Lt; Td width = "62%" & gt; & Lt; Div class = "editor-field" & gt; @ Html.EditorFor (model => model.LastName) @ html.ValidationMessageFor (model => model.LastName) & lt; / Div & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td width = "38%" & gt; Email address: & lt; / Td> & Lt; Td width = "62%" & gt; & Lt; Div class = "errorMessage" & gt; @ Html.EditorFor (model => model.EmailAddress) @ HTML.ValidationMessageFor (model => model.EmailAddress) & lt; / Div & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td width = "38%" & gt; Status: & lt; / Td> & Lt; Td width = "62%" & gt; & Lt; Div class = "editor-field" & gt; @ Html.DropDownList ("Status", ViewData ["Status"] as Selection List) & lt; / Div & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; Input type = "button" id = "btnCreateEmail" value = "save" name = "submit" class = "btn" /> & Lt; Input type = "button" value = "cancel" name = "cancel" category = "close door" /> & Lt; / Form & gt; }}   

- Controller

  [HTTPPT] Make public actional content email () {if (request.saaxxurist ()) {var list = new selectList (new [] {New {id} "active", name = "active"}, new {id = "idle", name = "idle"}}, "id", "name", 1); See data ["status"] = list; Back partial view ("_EmailEmail"); } Redirect return action ("index"); } [HTTPPist] {if (ModelState.IsValid)} {_emailRepository.Create (model)} using the Public Action Result e-mail (e-mail model) {(_emailRepository); Return Jason (new {success = true}); } Redirect return action ("index");  

/ P>
  $ (document) .ready (function (e) {$ ("form") .validate (). Element ("#FirstName"); $ ("form"). Validate () Element ("#LastName");});    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -