Friday, 15 May 2015

c# - How to configure client side validation only for onfocusout event -



c# - How to configure client side validation only for onfocusout event -

here jquery unobtrusive adapter using client side validation in mvc application. right validation working doing on onkeupevent . looking have clientside validation fireup after user leaves field - guide me on how working?. want set configuration fields not entire form.

jquery.validator.unobtrusive.adapters.add("compareemail", ["otherproperty"], function (options) { options.rules["compareemail"] = options.params.otherproperty; options.messages["compareemail"] = options.message; }); jquery.validator.addmethod("compareemail", function (value, element, params) { var reasonelement = $('#personaldetailsemail'); var testval = reasonelement.val(); if (value != testval) { homecoming false; } homecoming true; });

thankyou

if understand correctly, need:

$('.parentoffields').on( "blur", '.fieldsthatyouneedandhavethisclass', function(){ console.log($(this)) //do stuff $(this) } )

careful: create sure .parentoffields exists before js code executed, same not apply .fieldsthatyouneedandhavethisclass, can created/added on fly

more on blur here: http://api.jquery.com/blur/ blur means unfocus

c# jquery asp.net-mvc jquery-ui asp.net-mvc-4

No comments:

Post a Comment