Cart Buy Licenses Contact Integrate into App Docs Support Login/Register
v 1.8.68
v 1.8.68
Overview Examples Docs Source Download

Server Validators

Example of using onServerValidateQuestions callback

            Survey.defaultBootstrapCss.navigationButton = "btn btn-green";

//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) {
    //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(sender) {
            document.querySelector('#surveyResult').textContent =
            "Result JSON:\n" + JSON.stringify(, null, 3);
            var app = new Vue({
            el: '#surveyElement',
            survey: survey
<!DOCTYPE html>
<html lang="en">
    <title>Example of using onServerValidateQuestions callback, Vue Survey Library Example</title>

<meta name="viewport" content="width=device-width" />
    <script src=""></script>
    <script src=""></script>
    <script src="/DevBuilds/survey-vue/survey.vue.min.js"></script>
    <link rel="stylesheet" href="">
    <link rel="stylesheet" href="./index.css">

            <div id="surveyElement" style="display:inline-block;width:100%;">
                <survey :survey='survey' />
    <div id="surveyResult"></div>

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