Post in category

Setting the callback function after validation

Updated this month

Foxentry validators allow you to validate the entered data, be it the address, business name, name, phone number or email address. Each validator evaluates the correctness of the entered data and visually displays the result of the validation to the user in the browser in the form of an icon and a frame. If you don't want to display the user's default validation output but want to process the validation result first and then decide for yourself what you will display to the user and in what form, this behavior can be turned off in project administration.

Sso-called "callbacks" are used for the actual processing of the validation result. They are javascript functions that Foxentry runs after validation of the data. Each callback obtains information from the validator on the validity of the entered data (valid/invalid) and other data related to the subject of validation (eg address point details, company details, etc.). You can then process this data as you wish (for example, list it for the user).

There are 5 types of validators in Foxentry, and each type has an assigned code that can work with it. Use this code to set the callback function for a given type of validator.

Callback implementation method

Each callback must exist as a javascript function with one input parameter. Foxentry inserts the validator of the validation output into this parameter, so information on the validity of the data and possibly details of the validated data.

Types of Foxentry validators and their codes:

  • address validator (code "address")
  • company validator (code "company")
  • name and surname validator (code "name")
  • email address validator ("email" code) a
  • phone number validator ("phone" code).

Each of your callback functions can have a name. However, you need to report this Foxentry name via the "onFoxentryProjectLoad" function, which, if it exists (defined in your javascript code), starts automatically when you start Foxentry and load your project into the browser. Thus, you can create this function and define the callback function like in the code below. You don't need to define callback functions for all types of validators.

// code to insert Foxentry, use your own
var Foxentry, e = document.querySelector("script"), s = document.createElement('script');
s.setAttribute('type', 'text/javascript');
s.setAttribute('async', 'true');
s.setAttribute('src', '');
s.onload = function(){ 
  Foxentry = new FoxentryBase('foxentryform');      
// function that runs when Foxentry project is loaded into browser
function onFoxentryProjectLoad(){
  // definice callback funkcí, můžete nadefinovat všechny nebo jen některé
      "address" : addressValidationHandler,
      "company" : companyValidationHandler,
      "email"   : emailValidationHandler,
      "name"    : nameValidationHandler,
      "phone"   : phoneValidationHandler,
// the callback functions themselves, in which you process the output from validators   

function addressValidationHandler(data, validatorInfo){
  console.warn("address validation response", data, validatorInfo);

function companyValidationHandler(data, validatorInfo){
  console.warn("company validation response", data, validatorInfo);

function emailValidationHandler(data, validatorInfo){
  console.warn("email validation response", data, validatorInfo);

function nameValidationHandler(data, validatorInfo){
  console.warn("name validation response", data, validatorInfo);

function phoneValidationHandler(data, validatorInfo){
  console.warn("phone validation response", data, validatorInfo);

Still having trouble? Leave us a note.