asp.net mvc - JQueryValidation with MVC 4 not validating on blur -


i beating head on wall hours mvc 4 , jquery validation validate first first on blur. have tried attaching validation entire form , individual element (first field) no avail. if add alert() blur event seems fire no validation of required field. have additional validations add after required working haven't gotten them yet. don't know problem mvc 4. jqueryvalidate v1.10. have tried setting validator , calling .valid() on element want validated using .blur , still not validation can see.

$(function () {     $('#productionorder').focus();      $.validator.addmethod("cminlength", $.validator.methods.minlength,         $.format("must contain least {0} chars"));     $.validator.addclassrules("productionorder", { cmnlength: 3 });      $('#myform').validate({         onkeyup: false,         //onfocusout: false,         errorclass: 'fielderror'         //rules: {         //    productionorder: "required number",         //    tc: "required",         //    dn: "required"         //}     });      $("#towcount").bind("change keyup", function () {         $form.validate().element("#towcount");     });      //$('#productionorder').validate({     //    //onkeyup: false,     //    onfocusout: false,     //    errorclass: 'fielderror',     //    rules: {     //        productionorder: {      //            required: true      //        }     //    }     //}); }); 

and .cshtml

@model fiberline2.viewmodels.creel @{     layout = null; } <!doctype html> <html> <head>     <meta name="viewport" content="width=device-width" />     <title>test</title>     <script src="~/scripts/jquery-1.8.2.min.js"></script>     <script src="~/scripts/jquery.validate.min.js"></script>     <style>         .fielderror {             border-color: red;             border-width: medium;         }          .input-label {             font-size: 13px;             width: 130px;             height: 30px;             display: inline-block;         }     </style> </head> <body>     <form id="myform">         @html.antiforgerytoken()         @html.validationsummary(true)          <div>             <!-- app header -->             <label>@resources.strings.user: </label>             <label>@user.identity.name</label>         </div>         <fieldset>             <legend>@resources.strings.creel @resources.strings.load</legend>             <div>                 <div id="errordiv"></div>                 <hr />                 @html.label(@resources.strings.productionorder, new { @class = "input-label lock" })                 <input type="text" id="productionorder" name="productionorder" class="required" maxlength="4" />                 <br />                 <label class="input-label lock">@resources.strings.tow  @resources.strings.count</label>                 <input type="text" id="towcount" name="tc" class="required" size="5" maxlength="5" value="299" />                 <br />                 <label class="input-label lock">@resources.strings.batch @resources.strings.sequence</label>                 <input type="text" id="doffnumber" name="dn" size="5" maxlength="5" value="1" />                 <br />                 <label class="input-label">@resources.strings.creel @resources.strings.position</label>                 <input type="text" id="creelposition" name="cp" size="5" maxlength="5" />                 <br />                 <label class="input-label">@resources.strings.batch @resources.strings.id</label>                 <input type="text" id="creelnumber" name="cn" size="7" maxlength="7" />                 <br />                 <hr />             </div>             <p>                 <input type="submit" value="create" />             </p>         </fieldset>     </form> </body> </html> 

can try instead?

var settngs = $.data($('#myform')[0], 'validator').settings; settngs.onkeyup = false; 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -