javascript - Parsley.JS - Get an error list using callback -


in project don't want display html errors, throw alert() list of errors on formsubmit. guess should done somehow using listeners:onformsubmit callback, none of passed variables not contain "clean" version of errors. parsley documentation lacks of feature.

as of version 2.0, can access error messages via parsleyui.geterrorsmessages(fieldinstance)

example:

<form method="post" id="myform">     <input type="text" name="phone" value="" class="required" data-parsley-type="integer" />     <input type="submit" value="go"> </form>  <script type="text/javascript">     $(document).ready(function() {         $("#myform").parsley();          $.listen('parsley:field:error', function(fieldinstance){             // messages & alert             var arrerrormsg = parsleyui.geterrorsmessages(fieldinstance);             var errormsg = arrerrormsg.join(';');             alert(errormsg);              // name of input error             alert(fieldinstance.$element.attr('name'));         });     }); </script> 

also take @ following question display parsley errors in bootstrap tooltip


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -