jquery - MVC unobtrusive attibutes based validation requires more than one click -


I am using controversial features with MVC 4. I have a fairly standard input form. I have all the fields empty at the beginning. I have a problem with the selection (drop down list). This is a required field and the failure status is as follows:

  1. Click on (Verification message and turns on red frame)
  2. Choose value in the drop down list (verification message and frame still showing; hidden after clicking outside the drop down message But fr In no).
  3. Click the submit button.

If the user does not click outside after selection, the value from the drop down list will not be valid until the value is repeated twice, although the first click is not a click, but the drop Only "Focus" has been lost in the down list.

Is there any other way to force with any type of force with jQuery? I tried to click on the submit button and execute valid validation of jQuery on the selection event on the drop down list, both with no results.

My partial view looks like the following:

edit code @ @ edit HTML; HtmlHelper.UnobtrusiveJavaScriptEnabled = True; } @using (@ html.BeginForm (Model.ActionName, Model.ControllerName, FormMethod.Post, new {id = "editForm"})) {& lt; Div class = "sth_form" & gt; & Lt; Div class = "frm_row" & gt; @ Html.LabelFor (model => model.FIELD1) & lt; Div class = "frm_row_input" & gt; @ Html.TextBoxFor (model => model.FIELD1) @ html.ValidationMessageFor (model => model.FIELD1) & lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "frm_row" & gt; @html.labelfor (model => model.FIELD2) & lt; Div class = "frm_row_input" & gt; @ Html.TextBoxFor (model => model.FIELD2) @ html.ValidationMessageFor (model => model.FIELD2) & lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "frm_row" id = "contractor header" & gt; @ Html.LabelFor (model => model .content) & lt; Div class = "frm_row_input" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "frm_row" id = "contractor row" & gt; & Lt; Div class = "frm_row_input" id = "Contractor dropdown list" & gt; @ Html.DropDownListFor (model = & gt; model.contentor, model.contentors) @html. Validity message (model = & gt; model. Contractor) & lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "text_rgt" & gt; & Lt; Input type = "submit" name = "save" value = "@model.blood save" /> & Lt; Input type = "submit" name = "reset" value = "@ models. Label reset" /> & Lt; / Div & gt; }

My view:

  @ model editVM @ html.partial (MVC.Shared.Views.Sth._Edit, model)  < / Pre> 

My Controller Actions:

  [HTTPGet] Include Public Virtual ActionsSaltult () {#region Model Model Model = New EditWimbler (). BuildInsert (); PrepareBaseProperties (model); LoadDropListForSth (model); #ndrian return view (model); } [HTTPS] Insert Public Virtual Action Result (Admitima Model) {If (Request.form ["Save"] = Faucet) {if (ModelState.IsValid) {#region Save Mapper.CreateMap & lt; EditVM, SthModel & gt; (); Stemodal sth = new stemodel (); Mapper Map (model, STH); _dataAccess.SthAdd (sth); _dataAccess.SaveChanges (); #endregion #region Results Results Results Results = String Format ("{0}: {1}", Resource. The result messages. Some messages, models. FIELD1); Model.ResultMessage = Result Messages; PrepareBaseProperties (model); See #endrian returns (MVC.Shared.Views._Message, model); }} If (request.form ["reset"] = null) {ModelState.Clear (); Turn it back. } // validation model = new editVMBuilder (). ConfigureInstreet (model); PrepareBaseProperties (model); LoadDropListForSth (model); See Return (Model); }  


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -