javascript - parsley.js - manually display a message without having to validate -


i want display parsley message in else clause of javascript code:

if ( ...is valid ) {     //do things } else {     //display parsley error } 

i know parsley allows custom validators documented here: http://parsleyjs.org/documentation.html#javascript

but merely want display message until field modified. create validator such as:

$( '#myinput' ).parsley( {     validators: {       alwaysfalse: function ( val ) {         return false;       }     }   , messages: {       mymessage: "form invalid"     } }); 

but how trigger , validator? (there validator attached)

your messages object should mirror of validators object messages display.

messages: {   alwaysfalse: "form invalid" } 

and try

validators: {   alwaysfalse: function(val){     return false;   },   required: function ( val ) {     return false;   } } 

also

warning : must remove parsley-validate auto-binding code in forms dom allow override default processing , use parsley purely javascript.

it seems want this: http://parsleyjs.org/documentation.html#parsleyfield check out parsley-error-container

the trigger should $( '#myinput' ).parsley( 'validate' );

or not 100% sure on should able call each 1 this:

$( '#myinput' ).parsley('alwaysfalse'); 

and if need inputs or data:

$( '#myinput' ).parsley('alwaysfalse','inputs','data'); 

Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -