//default mode is "submit"
$('#form').djValidator();
//explicitly:
$('#form').djValidator({mode:'submit'});
When submit event is launched (click on the submit button), the complete validation will be carried out and the shipment will be stopped if there are invalid fields and will automatically send when everything is correct.
Field by field validation is enabled by default (blur).
In this mode you can run the plugin on one or several forms at the same time.
var resp=$(“#my-form”).djValidator({mode:”function”});
In function mode the validator work as a function and immediately returns true or false, it can be used when the form is sent via code (ajax):
if(resp==true){sendForm(“#my-form”);}
The function returns null when using the ajax validator, in that case you must include your code within the success property of the plugin (see server validation for more detail):
$(“#my-form”).djValidator(
mode:”function”,
success: function($form){
sendForm($form);
}
);
This mode runs the plugin on a single form, throwing an error otherwise.
The success property receives the function that will be executed at the end of the validation correctly when the mode is submit or the ajax validator is used in function mode:
$('#submit_btn').click(function(){
var resp=$('#my-form').djValidator({
mode:'submit',
success:
function(){
alert('validation success');
}
});
});
The default function is function($form){return true;}
In case of server validation, this function is required.
When the submit mode is used:$(“#my-form”).djValidator({blur:true});
In this mode the default value is true, in case of placing false the validation is done only when the submit event is launched (click on the submit button).
When using the function mode:$(“#my-form”).djValidator({mode:”blur”});
This code must be executed before: $(“#my-form”).djValidator({mode:”function”});
If the blur mode is not executed , the validation is only performed when the function is executed.
var resp=$(“#my-input”).djValidator();
//de forma explícita:
var resp=$(“#my-input”).djValidator({mode:”submit”});
In submit mode you can also run the plugin on a single field, in this case it is executed just like the function mode by returning true or false.
$(“#my-form”).djValidator({mode:”clean”});
When you run the plugin in this mode, all validation messages are cleaned immediately and the border color is restored.
Several validators can be used in the same field, using the “&” operator to chain them
<input type="text" data-dj-validator="atext,3,12&word,3,12">
The validations are applied in order, but the final result will always be the same.