Server Validators

Example of using onServerValidateQuestions callback

                        //assign call to onServerValidateQuestions callback
function surveyValidateQuestion(survey, options) {
    // contains the data for the current page.
    var countryName =["country"];
    //If the question is empty then do nothing
    if (!countryName) options.complete();
    //call the ajax method
        url: ""
    }).then(function (data) {
        var found = false;
        var countries = data;
        for (var i = 0; i < countries.length; i++) {
            if (countries[i].name == countryName) {
                found = true; break;
        //if the country is unknown, add the error
        if (!found) options.errors["country"] = "The country name '" + countryName +"' is not in this list:";
        //tell survey that we are done with the server validation


var json = {
    questions: [{ type: "text", name: "country", title: "Type a country:" }]

window.survey = new Survey.Model(json);

    survey.onComplete.add(function(result) {
        document.querySelector('#surveyResult').textContent =
            "Result JSON:\n" + JSON.stringify(, null, 3);


<!DOCTYPE html>
    <title>Example of using onServerValidateQuestions callback, Knockoutjs Survey Library Example</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src=""></script>
    <script src=""></script>
<script src=""></script>
<link href="" type="text/css" rel="stylesheet" />
    <link rel="stylesheet" href="./index.css">

                <div id="surveyElement">
    <div id="surveyResult"></div>

<script type="text/javascript" src="./index.js"></script>