jquery - Hook success event MVC validation (per field) -
i'm removing default error messages on form , i'm replacing them tooltips.
is there way capture validation event each field?
when users starts typing text in "asset name" textbox red background on textbox disappears. remove tooltip well.
this how i'm building tooltips:
$("#frmasset").submit(function (evt) { var myvalues = new array(); var mynames = new array(); var errors = $(".input-validation-error"); errors.each(function (index) { var name = $(this)[0].id; var value = $('span[for="' + name + '"]')[0].innertext; mynames[index] = name; myvalues[index] = value; }); // build , show tooltop error messages $.each(myvalues, function (index) { tipped.create($("#" + mynames[index]), myvalues[index], { skin: 'red', hideon: test(), hook: { target: 'rightmiddle', tooltip: 'leftmiddle' } }).show(); }); // hide built-in error messages $('.field-validation-error').hide(); var valid = $("#frmasset").valid(); if (valid == true) { $.ajax({ type: "post", url: "/asset/create", data: $("#frmasset").serialize(), success: function (data) { alert('success!'); console.log(data.message); // close popup window var window = $('#asseteditorpopup').data("kendowindow"); window.close(); // refresh grid show changes $('#grid').data("kendogrid").datasource.read(); }, error: function () { alert("there error adding asset."); } }); } return false; });
here small wrapper hooks you: https://gist.github.com/remi/957732
you'll need elementvalidationsuccess
hook.
Comments
Post a Comment