The messages style can be changed by modifying these parameters:
style: are the styles that will be applied to validation messages, these styles are inline, “display: none” must be placed to add FadeIn effect.
template: The html template with which the validation messages will be inserted, the class dj-validator-msg
must be retained to identify and delete the validation messages, in the "$style" mark the value of the "style" property is inserted and in the mark $msg validation message is inserted, both must be retained.
decorate: Change the border of invalid fields according to the border_color parameter, it can be true (default) or false.
border_color: Border color for fields when the decorate parameter is true, it can be a standard html color value (name, hexadecimal or rgb).
//Default values:
$(“#my-form”).djValidator({
style:'display:none; color:red; text-align:inherit; font:italic bold .9em sans-serif',
template:'<p class="dj-validator-msg" style="$style">$msg</p>'
decorate: true,
border_color: 'red'
});
Use the attribute data-dj-validator-msg
in any field to change the default validation message to your own:
<input name="user" required data-dj-validator-msg="Please fill the user!">
Use the global function $.fn.djValidator.setLabels
modify the messages you want or make a translation into another language:
$.fn.djValidator.setLabels({
required:'Campo requerido.',
word_min:'Por lo menos $1 caracteres sin espacios.',
word_between:'Entre $1 y $2 caracteres sin espacios.',
atext_min:'Por lo menos $1 caracteres alfabéticos.',
......
});
In the brands $1, $2, etc. The plugin inserts the respective parameters used by your validator (See the Spanish translation file for a more complete example)
See the table of labels to know them all.
Use the global variable $.fn.djValidator.props
, to change the default values of the plugin:
$.fn.djValidator.props={
mode: 'submit',//submit function clean blur
blur: true,
decorate: true,
border_color: 'red',
style:'display:none; color:red; text-align:inherit; font:italic bold .9em sans-serif',
template:'<p class="dj-validator-msg" style="$style">$msg</p>',
request_method: 'post',
success: function($form){return true;}
};
Check the available options for reference.