asp.net mvc 4 - Client Side Validation not working in Modal dialog -


i have modal popup dialog box loads form submitted database. form works fine if fields filled out. if leave blank fields , click create button validation should kick in not. following error: validation failed 1 or more entities. see 'entityvalidationerrors' property more details. know error is. values in fields null , cannot null submit database. modelstate false well. model:

using system.componentmodel.dataannotations; using mvc_csalerts.models;   namespace mvc_csalerts.models  { using system; using system.collections.generic; using system.componentmodel;  public partial class csalert {     public int alertid { get; set; }       [required(allowemptystrings = false, errormessage = "must enter route")]     public string routes { get; set; }      [required(allowemptystrings = false, errormessage = "must enter issue")]     public string issue { get; set; }      public string detour { get; set; }      [displayname("date")]     [datatype(datatype.datetime)]     [required]     public nullable<system.datetime> dateentered { get; set; }      [required]     [displayname("entered by")]     public string enteredby { get; set; }      public nullable<int> count { get; set; }      [displayname("send email")]     public string sendemail { get; set; }      [displayname("is child alert")]     public string ischildalert { get; set; } } } 

this view

  @model mvc_csalerts.models.csalert     @{ viewbag.title = "create";  }  <h2>create new alert</h2>    <script type="text/javascript">         $(document).ready(function () {             // test datapicker             $('#dateentered').datepicker();             // test tabs             $(function () {                 $(document).tooltip();             });         });      </script>    @using (ajax.beginform("create","alerts",new ajaxoptions()))   { @html.antiforgerytoken() @html.validationsummary(true)   <fieldset>     <legend>new alert</legend>       <div class="editor-label">         @html.labelfor(model => model.routes)     </div>     <div class="editor-field">         @html.editorfor(model => model.routes)         @html.validationmessagefor(model => model.routes)     </div>      <div class="editor-label">         @html.labelfor(model => model.issue)     </div>     <div class="editor-field">         @html.textareafor(model => model.issue)         @html.validationmessagefor(model => model.issue)     </div>      <div class="editor-label">         @html.labelfor(model => model.detour)     </div>     <div class="editor-field">         @html.textareafor(model => model.detour)         @html.validationmessagefor(model => model.detour)     </div>      <div class="editor-label">         @html.labelfor(model => model.dateentered)         @html.validationmessagefor(model => model.dateentered)     </div>     <div class="editor-field">          @html.jqueryui().datepickerfor(model => model.dateentered)         @html.validationmessagefor(model => model.dateentered)     </div>     <div class="editor-label">         @html.labelfor(model => model.count)     </div>     <div class="editor-field">         @html.editorfor(model => model.count)         @html.validationmessagefor(model => model.count)     </div>      <div class="editor-label">         @html.labelfor(model => model.sendemail)     </div>     <div class="editor-field">                           @html.dropdownlistfor(model => model.sendemail, new               selectlist(new list<object>{    new{ value = "y", text="yes"},     new{ value = "n",text="no"}                                                                                  },     "value",     "text",                                                                                  "y"))        @*                  @html.editorfor(model => model.sendemail)*@         @html.validationmessagefor(model => model.sendemail)     </div>      <div class="editor-label">         @html.labelfor(model => model.ischildalert)     </div>        <div class="editor-field>   @html.dropdownlistfor(model =>             model.ischildalert, new selectlist(new list<object>{    new{ value = "y", text="yes"},     new{ value = "n",text="no"}                                                              },    "value",    "text",                                                                                  "y"))          @*            @html.editorfor(model => model.ischildalert)*@         @html.validationmessagefor(model => model.ischildalert)     </div>      <p>         <input type="submit" value="create new alert" />     </p> </fieldset>   }     @section scripts {    @scripts.render("~/bundles/jqueryval")   } 

how clientside validation load? have javascript validation in modal window?

thanks

try moving your: @scripts.render("~/bundles/jqueryval") parent view instead of having in modal view.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

mysql - Pass value between different pages (form) with PHP -