Callbacks
The callbacks object
In callbacks object you can pass custom functions to be executed in differents parts of the plugins execution.
callbacks: {
eachFieldError: null,
eachFieldSuccess: null,
requiredError: null,
requiredSuccess: null,
emailError: null,
emailSuccess: null,
integerError: null,
integerSuccess: null,
digitError: null,
digitSuccess: null,
numericError: null,
numericSuccess: null,
phoneError: null,
phoneSuccess: null,
urlError: null,
urlSuccess: null,
dateError: null,
dateSuccess: null,
currencyError: null,
currencySuccess: null,
cepError: null,
cepSuccess: null,
maxLengthError: null,
maxLengthSuccess: null,
minLengthError: null,
minLengthSuccess: null,
rangeLengthError: null,
rangeLengthSuccess: null,
sameLengthError: null,
sameLengthSuccess: null,
maxError: null,
maxSuccess: null,
minError: null,
minSuccess: null,
rangeError: null,
rangeSuccess: null,
equalToError: null,
equalToSuccess: null,
cpfError: null,
cpfSuccess: null,
cnpjError: null,
cnpjSuccess: null,
cnhError: null,
cnhSuccess: null,
creditCardSuccess: null,
creditCardError: null,
hasExtensionSuccess: null,
hasExtensionError: null,
patternError: null,
patternSuccess: null,
beforeValidate: null,
afterValidate: null,
error: null,
success: null
}
Example:
var config = {
callbacks: {
afterValidate: function(element){
console.log('afterValidateError', element);
},
eachFieldError: function(element){
console.log('eachFieldError', element);;
},
emailSuccess: function(element){
console.log('emailSuccess', element);;
}
}
};
var validator = new VanillaValidator(config);
| Key | Type | Default | Description |
|---|---|---|---|
| eachFieldError | Function |
null | A function that will be executed after the error of each field which has a validation rules attributed to it. As parameter that function receive the element field. |
| eachFieldSuccess | Function |
null | A function that will be executed after the success of each field which has a validation rules attributed to it. As parameter that function receive the element field. |
| requiredError | Function |
null | A function that will be executed after the error of each field which has a required validation rule attributed to it. As parameter that function receive the element field. |
| requiredSuccess | Function |
null | A function that will be executed after the success of each field which has a required validation rule attributed to it. As parameter that function receive the element field. |
| emailError | Function |
null | A function that will be executed after the error of each field which has an email validation rule attributed to it. As parameter that function receive the element field. |
| emailSuccess | Function |
null | A function that will be executed after the success of each field which has an email validation rule attributed to it. As parameter that function receive the element field. |
| integerError | Function |
null | A function that will be executed after the error of each field which has an integer validation rule attributed to it. As parameter that function receive the element field. |
| integerSuccess | Function |
null | A function that will be executed after the success of each field which has an integer validation rule attributed to it. As parameter that function receive the element field. |
| digitError | Function |
null | A function that will be executed after the error of each field which has a digit validation rule attributed to it. As parameter that function receive the element field. |
| digitSuccess | Function |
null | A function that will be executed after the success of each field which has a digit validation rule attributed to it. As parameter that function receive the element field. |
| numericError | Function |
null | A function that will be executed after the error of each field which has a numeric validation rule attributed to it. As parameter that function receive the element field. |
| numericSuccess | Function |
null | A function that will be executed after the success of each field which has a numeric validation rule attributed to it. As parameter that function receive the element field. |
| phoneError | Function |
null | A function that will be executed after the error of each field which has a phone validation rule attributed to it. As parameter that function receive the element field. |
| phoneSuccess | Function |
null | A function that will be executed after the success of each field which has a phone validation rule attributed to it. As parameter that function receive the element field. |
| urlError | Function |
null | A function that will be executed after the error of each field which has an url validation rule attributed to it. As parameter that function receive the element field. |
| urlSuccess | Function |
null | A function that will be executed after the success of each field which has an url validation rule attributed to it. As parameter that function receive the element field. |
| dateError | Function |
null | A function that will be executed after the error of each field which has a date validation rule attributed to it. As parameter that function receive the element field. |
| dateSuccess | Function |
null | A function that will be executed after the success of each field which has a date validation rule attributed to it. As parameter that function receive the element field. |
| currencyError | Function |
null | A function that will be executed after the error of each field which has a currency validation rule attributed to it. As parameter that function receive the element field. |
| currencySuccess | Function |
null | A function that will be executed after the success of each field which has a currency validation rule attributed to it. As parameter that function receive the element field. |
| cepError | Function |
null | A function that will be executed after the error of each field which has a cep validation rule attributed to it. As parameter that function receive the element field. |
| cepSuccess | Function |
null | A function that will be executed after the success of each field which has a cep validation rule attributed to it. As parameter that function receive the element field. |
| maxLengthError | Function |
null | A function that will be executed after the error of each field which has a max length validation rule attributed to it. As parameter that function receive the element field. |
| maxLengthSuccess | Function |
null | A function that will be executed after the success of each field which has a max length validation rule attributed to it. As parameter that function receive the element field. |
| minLengthError | Function |
null | A function that will be executed after the error of each field which has a min length validation rule attributed to it. As parameter that function receive the element field. |
| minLengthSuccess | Function |
null | A function that will be executed after the success of each field which has a min length validation rule attributed to it. As parameter that function receive the element field. |
| rangeLengthError | Function |
null | A function that will be executed after the error of each field which has a range length validation rule attributed to it. As parameter that function receive the element field. |
| rangeLengthSuccess | Function |
null | A function that will be executed after the success of each field which has a range length validation rule attributed to it. As parameter that function receive the element field. |
| sameLengthError | Function |
null | A function that will be executed after the error of each field which has a same length validation rule attributed to it. As parameter that function receive the element field. |
| sameLengthSuccess | Function |
null | A function that will be executed after the success of each field which has a same length validation rule attributed to it. As parameter that function receive the element field. |
| maxError | Function |
null | A function that will be executed after the error of each field which has a max validation rule attributed to it. As parameter that function receive the element field. |
| maxSuccess | Function |
null | A function that will be executed after the success of each field which has a max validation rule attributed to it. As parameter that function receive the element field. |
| minError | Function |
null | A function that will be executed after the error of each field which has a min validation rule attributed to it. As parameter that function receive the element field. |
| minSuccess | Function |
null | A function that will be executed after the success of each field which has a min validation rule attributed to it. As parameter that function receive the element field. |
| rangeError | Function |
null | A function that will be executed after the error of each field which has a range validation rule attributed to it. As parameter that function receive the element field. |
| rangeSuccess | Function |
null | A function that will be executed after the success of each field which has a range validation rule attributed to it. As parameter that function receive the element field. |
| equalToError | Function |
null | A function that will be executed after the error of each field which has an equal to validation rule attributed to it. As parameter that function receive the element field. |
| equalToSuccess | Function |
null | A function that will be executed after the success of each field which has an equal to validation rule attributed to it. As parameter that function receive the element field. |
| cpfError | Function |
null | A function that will be executed after the error of each field which has a cpf validation rule attributed to it. As parameter that function receive the element field. |
| cpfSuccess | Function |
null | A function that will be executed after the success of each field which has a cpf validation rule attributed to it. As parameter that function receive the element field. |
| cnpjError | Function |
null | A function that will be executed after the error of each field which has a cnpj validation rule attributed to it. As parameter that function receive the element field. |
| cnpjSuccess | Function |
null | A function that will be executed after the success of each field which has a cnpj validation rule attributed to it. As parameter that function receive the element field. |
| cnhError | Function |
null | A function that will be executed after the error of each field which has a cnh validation rule attributed to it. As parameter that function receive the element field. |
| cnhSuccess | Function |
null | A function that will be executed after the success of each field which has a cnh validation rule attributed to it. As parameter that function receive the element field. |
| creditCardError | Function |
null | A function that will be executed after the error of each field which has a credit card validation rule attributed to it. As parameter that function receive the element field. |
| creditCardSuccess | Function |
null | A function that will be executed after the success of each field which has a credit card validation rule attributed to it. As parameter that function receive the element field. |
| hasExtensionError | Function |
null | A function that will be executed after the error of each field which has a has extension validation rule attributed to it. As parameter that function receive the element field. |
| hasExtensionSuccess | Function |
null | A function that will be executed after the success of each field which has a has extension validation rule attributed to it. As parameter that function receive the element field. |
| patternError | Function |
null | A function that will be executed after the error of each field which has a pattern validation rule attributed to it. As parameter that function receive the element field. |
| patternSuccess | Function |
null | A function that will be executed after the success of each field which has a pattern validation rule attributed to it. As parameter that function receive the element field. |
| beforeValidate | Function |
null | A function that will be executed before validation of the container. As parameter that function receive the element container. |
| afterValidate | Function |
null | A function that will be executed after validation of the container. As parameter that function receive the element container. |
| error | Function |
null | A function that will be executed when the validation is fail. As parameter that function receive the element container. |
| success | Function |
null | A function that will be executed when the validation is successful. As parameter that function receive the element container. |