parsley.js - Custom remote validator error message -


with custom remote validator, how supposed rid of error messages?

using data-parsley-remote-validator='mycustom' on field give error in console 'undefined async validator' unless validator added on dom ready i.e not inside function. however, if added on dom ready, parsley automatically calls it, shouldn't happen until submit/change or whatever else have set.

i can this, kind of defeats object of having parsley call validator on change:

$('#signupform').on('submit', function() { //add attribute here avoid initial error message   $('#exampleinputemail1').attr('data-parsley-remote-validator', 'validateemail'); //then add custom validator   $('#exampleinputemail1').parsley()   .addasyncvalidator('validateemail', function (xhr) {            if(xhr.status == '200') {                return 200;              }           // return error message if email taken            else if(xhr.status == '404') {              response = '<ul class="errorlist"><li>that email has been taken, please try another</li></ul>'              $('#errorresponse').html(response);             }       }, '/api/v1/email/available', { "type": "post", "datatype": "json", "data": data }    );  }); 

for came here custom remote validator error message in parsley.js,

you can add data-parsley-remote-message element,

<input type="text"  data-parsley-remote-validator="my_remote_validator" data-parsley-remote-message="custom error message remote validation on element" > 

tested parsley.js - version 2.3.11


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -