For a complete sample file, scroll to the bottom of the guide


  1. Once you have completed setting up your survey choose which question blocks you need to add validation too.

  2. Click on the ‘gear’ icon on the left side of your question block:


  3. You will then see several options but the one we want is ‘Add JavaScript…’ as shown below:


  4. When the JavaScript screen pops up click on the option “Full Screen” in the bottom left corner to make it easier.

  5. The screen should be pre-populated with the following:


  6. We will be placing our code in the ‘addOnReady’ function, starting with the following section of code:


    This section of code will allow us to use a different version of jQuery and jQueryUi, which allows the autocomplete/ajax code to work on the survey, as well as:

    • It will set the variable for your Kleber RequestKey
    • A label that will display to the client if the response was valid or invalid

  7. Next, we will add the code that calls the Kleber platform to validate the address field:

    • Whilst not shown we can also set ‘minLength’ option of the autocomplete so that the search will only fire after a set number of characters
    • This code will pass values entered into the address field, to Kleber platform, where it will process and return possible addresses
    • We temporarily remove the ‘# results’ from the end of some strings as they are not needed, then pass the new string as a possible suggestion

  8. This next section will be how we handle the retrieve method when a customer selects an address, as well as what to do if the user doesnt select an address at all.

    • When a user selects an address we set an id variable and save the id as an array
    • We then check the first index of the array variable to determine which retireve method we should call next
    • With the international search, addresses from either the UK or Canada have a seperate retrieve price so we need to use those specific retrieves
    • When the user closes the search window without selecting an address, we set the other fields to empty and set a label to “Invalid”

  9. This section is for the function that will handle the Retrieve method for countries other then the UK or Canada.

    • Here we will populate the data with the recordId from the search method
    • In the response we will populate our fields with the returned address data
    • We have left the debug to console just to verify that the function works

  10. This section we will be dealing with the function responsible for results when search a Canadian address

    • Here we will populate the data with the recordId from the search method and will also use a different retrieve method
    • In the response we will populate our fields with the returned address data
    • We have left the debug to console just to verify that the function works

  11. This section we will be dealing with the function responsible for results when search an UK address

    • Here we will populate the data with the recordId from the search method and will also use a different retrieve method
    • In the response we will populate our fields with the returned address data
    • We have left the debug to console just to verify that the function works

Congratulations you have just integrated Kleber Email Validation into your Qualtrics survey. Please look at some of the other step-by-step guides if you wish to add additional validation.

Complete Sample code

Sample.txt