I'm using the Parsley plugin for form validation and I'm creating some additional validation methods, however, I'm having difficulty personalizing the messages of these functions.
According to the site documentation, we can add a custom method as follows:
window.Parsley.addValidator('equals', {
validateString: function validateString(value, comparar_com, texto_erro) {
return (value === comparar_com);
},
requirementType: 'string',
messages: {
pt_BR: 'O seguinte valor é esperado: %s'
}
});
With the code above Parsley would display in the error message the second parameter of the function, which would be 'compare_com', but I wanted the text defined in the third parameter, 'error_text', to be displayed in the error message, and not the 'compare_with'.
Can anyone tell me if this is possible? Parsley uses the following function to mount the error messages:
// Kind of light 'sprintf()' implementation
formatMessage: function formatMessage(string, parameters) {
...
I'm trying something here, still unsuccessful, but am I on the right track?