jquery - why $("#form_data").valid() is true even if it does not have any values -


i have used , when execute this, goes if , if field empty, please give me solution, validations not getting performed , have jquery , validate.js both

      @using (html.beginform("saveevent", "base", formmethod.post, new { id = "form_data", @class = "form-horizontal", style = "display: none;" }))      {             @html.validationsummary(true)                 @html.antiforgerytoken()      @*<form id="form_data" class="form-horizontal" style="display: none;">*@     <fieldset class="form-group">         <div>             <label class="control-label col-xs-12 col-sm-3 no-padding-right" style="font-weight: bold;                 font-size: 13px; font-family: arial unicode ms;">                 assign             </label>             <div class="col-xs-12 col-sm-9">                 <div class="clearfix">                     @html.dropdownlistfor(model => model.task_runsmodel.project_id, db.getusers(), "select user....", new { id = "task" })                 </div>             </div>         </div> <fieldset> } </div> 

model code

     public class task_runsmodel             //user use add tasks , comments     {          [display(name = "project name")]         [required(errormessage = "you can't leave empty.", allowemptystrings = false)]         public int project_id { get; set; }     } 

in jquery:

     if($("#form_data").valid())       {            var project_id=$('#myproject').val(),         task_id=$('#mytask').val(),     } 


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -