Tuesday, November 17, 2026
HomejQuerySurveyJS Type Library: JavaScript Surveys, Kinds & Quizzes

SurveyJS Type Library: JavaScript Surveys, Kinds & Quizzes


SurveyJS Type Library is a JavaScript library for rendering JSON-defined types, surveys, questionnaires, polls, and quizzes in fashionable internet apps. One survey mannequin holds the schema, validation guidelines, conditional logic, navigation state, and picked up responses. The identical mannequin works throughout plain JavaScript, jQuery, React, Angular, and Vue tasks. jQuery purposes can render it by means of the Survey() wrapper.

Options:

  • JSON-based surveys, types, suggestions flows, polls, and scored quizzes.
  • Multi-page types with conditional visibility, branching, validation, progress UI, timers, and preview mode.
  • Textual content, alternative, matrix, dynamic panel, file, signature, expression, ranking, and different built-in query fashions.
  • Browser renderer for plain JavaScript and jQuery tasks, plus React, Angular, and Vue 3 packages.
  • jQuery integration by means of the browser renderer and its Survey() wrapper.
  • Response information APIs, calculated values, customized variables, triggers, quiz scoring, partial outcomes, and server validation hooks.
  • File add hooks, lazy-loaded decisions, dynamic matrices, dynamic panels, and customized navigation actions.

Packages And jQuery Integration

Browser tasks use survey-core for the survey mannequin, validation, logic, localization, and response APIs. The survey-js-ui bundle renders that mannequin in a plain HTML, CSS, and JavaScript web page.









Mission Kind Package deal / Setup
HTML, CSS, JavaScript survey-core + survey-js-ui
jQuery software jQuery + survey-core + survey-js-ui; render with $("#surveyContainer").Survey({ mannequin: survey })
React survey-react-ui
Angular survey-angular-ui
Vue 3 survey-vue3-ui

Browser tasks use survey-core with survey-js-ui. The legacy survey-jquery bundle requires jQuery 1.12.4 or newer. Present jQuery purposes can maintain jQuery and use the Survey() wrapper uncovered by the browser renderer.

How To Use SurveyJS

1. Set up SurveyJS

For a browser web page, load the SurveyJS stylesheet, core mannequin, and browser renderer on this order:


<hyperlink
  href="https://unpkg.com/[email protected]/survey-core.min.css"
  kind="textual content/css"
  rel="stylesheet">

<script src="https://unpkg.com/[email protected]/survey.core.min.js"></script>
<script src="https://unpkg.com/[email protected]/survey-js-ui.min.js"></script>

For npm tasks, set up the mannequin and browser renderer:


npm set up survey-core survey-js-ui

React, Angular, and Vue tasks use the matching renderer bundle: survey-react-ui, survey-angular-ui, or survey-vue3-ui.

2. Add A Survey Container


<div id="surveyContainer"></div>

3. Outline The Survey In JSON

Query names turn out to be keys within the response information object. The next schema creates a brief multi-page suggestions survey with required alternative and ranking questions.


var surveyJson = {
  title: "Product Suggestions",
  showProgressBar: true,
  progressBarType: "pages",
  pages: [
    {
      name: "experience",
      title: "Your Experience",
      elements: [
        {
          type: "radiogroup",
          name: "usage_frequency",
          title: "How often do you use the product?",
          isRequired: true,
          choices: ["Daily", "Weekly", "Monthly", "Rarely"]
        },
        {
          kind: "ranking",
          title: "satisfaction",
          title: "How happy are you?",
          isRequired: true,
          rateMin: 1,
          rateMax: 5
        }
      ]
    },
    {
      title: "follow_up",
      title: "Comply with-up",
      components: [
        {
          type: "comment",
          name: "improvement",
          title: "What should we improve?",
          visibleIf: "{satisfaction} <= 3"
        },
        {
          type: "text",
          name: "email",
          title: "Email for follow-up",
          inputType: "email"
        }
      ]
    }
  ]
};

4. Create And Render The Mannequin

The worldwide browser construct exposes the mannequin constructor as Survey.Mannequin.


var survey = new Survey.Mannequin(surveyJson);

doc.addEventListener("DOMContentLoaded", perform () {
  survey.render(doc.getElementById("surveyContainer"));
});

5. Render SurveyJS In A jQuery Mission

jQuery tasks can render the identical survey mannequin by means of the Survey() wrapper. Load jQuery earlier than survey-js-ui.


<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://unpkg.com/[email protected]/survey.core.min.js"></script>
<script src="https://unpkg.com/[email protected]/survey-js-ui.min.js"></script>

var survey = new Survey.Mannequin(surveyJson);

$(perform () {
  $("#surveyContainer").Survey({
    mannequin: survey
  });
});

6. Learn The Accomplished Response

The information property comprises the present response object. onComplete runs after profitable completion.


survey.onComplete.add(perform (sender) {
  var consequence = sender.information;

  console.log(JSON.stringify(consequence, null, 2));

  // Ship `consequence` to your personal API or storage layer right here.
});

7. Apply A Theme

The Default Mild theme comes from the principle SurveyJS stylesheet. Load a theme script and name applyTheme() when the web page wants one other predefined theme.


<script src="https://unpkg.com/[email protected]/themes/contrast-light.min.js"></script>

survey.applyTheme(SurveyTheme.ContrastLight);

8. Intercept Completion

onCompleting helps asynchronous work and might cease completion when an exterior save or validation step fails.


survey.onCompleting.add(async perform (sender, choices) {
  strive {
    var response = await fetch("/api/survey-results", {
      technique: "POST",
      headers: {
        "Content material-Kind": "software/json"
      },
      physique: JSON.stringify(sender.information)
    });

    if (!response.okay) {
      choices.enable = false;
      choices.message = "The response couldn't be saved. Please strive once more.";
    }
  } catch (error) {
    choices.enable = false;
    choices.message = "The response couldn't be saved. Please strive once more.";
  }
});

SurveyModel Choices And Properties

This compact reference focuses on survey-level settings used most frequently in manufacturing types, surveys, and quizzes. Query-specific settings keep on the corresponding query mannequin courses.

Knowledge, Pages, And State









Choice / Property Description
information Will get or units the response information object.
pages Will get the survey web page assortment.
currentPage Will get or units the present web page.
currentPageNo Will get or units the zero-based index of the present seen web page.
state Will get the present survey state, similar to loading, beginning, working, preview, or accomplished.

Navigation And Progress
















Choice / Property Description
firstPageIsStartPage Determines if the primary web page acts as a begin web page.
navigationButtonsLocation Units the place the navigation buttons seem.
showNavigationButtons Controls visibility of built-in navigation buttons.
showPrevButton Controls visibility of the Earlier button.
showCompleteButton Controls visibility of the Full button.
showPreviewBeforeComplete Controls reply preview earlier than remaining completion.
showTOC Controls the survey desk of contents.
showProgressBar Controls progress bar visibility.
progressBarLocation Units the place the progress bar seems.
progressBarType Units the progress calculation mode.
progressBarShowPageNumbers Controls web page numbers within the progress bar.
progressBarShowNavigationText Controls web page navigation textual content within the progress bar.

Questions And Format













Choice / Property Description
questionOrder Units the query order coverage.
questionsOnPageMode Units the web page presentation mode: regular pages, one survey-wide web page, one query per web page, or one enter per web page.
showQuestionNumbers Units the query numbering mode.
requiredMark Units the marker proven for required questions.
questionTitleLocation Units the default query title place.
questionDescriptionLocation Units the place query descriptions seem.
questionErrorLocation Units the place validation errors seem for questions.
widthMode Units how SurveyJS calculates survey width.
lazyRenderEnabled Controls lazy rendering of survey components.

Validation And Enter












Choice / Property Description
checkErrorsMode Units when SurveyJS checks validation errors in the course of the survey stream.
validationEnabled Controls survey validation.
validationAllowComplete Controls completion when validation errors exist.
validationAllowSwitchPages Controls web page switching when validation errors exist.
validateVisitedEmptyFields Controls validation of empty fields {that a} respondent has visited.
clearInvisibleValues Units when values from hidden questions, panels, or pages are cleared.
textUpdateMode Units when textual content inputs write their values to the mannequin.
readOnly Controls read-only mode for the survey.

Completion And Redirects










Choice / Property Description
completedHtml Units the HTML proven after survey completion.
completedHtmlOnCondition Defines conditional completion HTML entries.
showCompletePage Determines if SurveyJS shows a completion web page.
partialSendEnabled Controls partial consequence sending throughout survey progress.
navigateToUrl Units the URL opened after completion.
navigateToUrlOnCondition Defines conditional completion URLs.

Logic, Locale, And Runtime














Choice / Property Description
locale Will get or units the survey locale.
calculatedValues Shops calculated values evaluated from expressions.
triggers Will get or units conditional logic triggers.
css Will get or units CSS class mappings utilized by the renderer.
elementIdPrefix Provides a prefix to generated HTML ingredient IDs. Set a singular worth when a number of surveys render on the identical web page.
autoAdvanceEnabled Controls computerized web page advance after respondents reply the required questions on a web page.
autoAdvanceAllowComplete Controls computerized completion on the final web page when computerized advance is energetic.
autoFocusFirstError Controls concentrate on the primary query with a validation error.
cookieName Units the cookie title used to detect a earlier completion.
jsonErrors Comprises errors discovered whereas loading a survey JSON definition.

Timer









Choice / Property Description
showTimer Controls timer visibility.
timerLocation Units the place timer data seems.
timeLimit Units the survey-wide time restrict in seconds.
timeLimitPerPage Units the per-page time restrict in seconds.
timeSpent Will get or units elapsed survey time in seconds.

SurveyModel Strategies

These strategies cowl the principle duties builders carry out after a survey mannequin is created.

Lifecycle And Navigation
















Technique Description
fromJSON Hundreds survey settings, pages, questions, and different mannequin information from JSON.
toJSON Serializes the survey mannequin to JSON.
dispose Releases mannequin sources and occasion handlers.
clear Clears survey response information.
nextPage Validates the present web page as required and strikes to the subsequent web page when navigation is permitted.
prevPage Strikes to the earlier seen web page.
begin Begins the survey when a begin web page is configured.
showPreview Switches the survey to reply preview mode.
cancelPreview Leaves reply preview mode and returns to survey modifying.
doComplete Completes the survey and runs the completion stream.
tryComplete Makes an attempt to finish the survey after working completion and validation checks.
focusQuestion Strikes focus to a query recognized by title or mannequin reference.

Response Knowledge










Technique Description
getData Returns response information, with filtering choices when equipped.
getValue Returns the response worth saved below a reputation.
setValue Shops a response worth below a reputation.
clearValue Clears the worth saved below a response key.
mergeData Merges an object into the present response information.
getPlainData Returns survey responses as a plain-data array suited to export or inspection.

Questions And Components










Technique Description
getAllQuestions Returns questions contained within the survey.
getElementByName Finds a survey ingredient by title.
getPageByName Finds a web page by title.
getPanelByName Finds a panel by title.
getQuestionByName Finds a query by its title.
getQuestionByValueName Finds a query that shops information below a specified worth title.

Variables, Logic, And Validation












Technique Description
getVariable Returns a customized survey variable.
setVariable Creates or updates a customized survey variable.
runCondition Evaluates a SurveyJS situation expression.
runExpression Evaluates a SurveyJS expression and returns its consequence.
runTriggers Evaluates and executes survey triggers.
validate Validates the survey.
validateCurrentPage Validates the present web page.
validatePage Validates a specified web page.

Quiz, Theme, Recordsdata, And Timer














Technique Description
getCorrectAnswerCount Returns the variety of appropriately answered quiz questions.
getIncorrectAnswerCount Returns the variety of incorrectly answered quiz questions.
getQuizQuestionCount Returns the variety of questions included in quiz scoring.
applyTheme Applies a theme object to the survey, with an elective base theme.
addNavigationItem Provides a customized motion to the survey navigation bar and returns the created motion.
notify Reveals a SurveyJS notification message.
uploadFiles Runs the SurveyJS file-upload stream for File questions.
getProgressInfo Returns progress data for the requested progress mode.
startTimer Begins the survey timer.
stopTimer Stops the survey timer.

SurveyModel Occasions

These occasions cowl the principle integration factors for navigation, validation, information modifications, rendering, dynamic content material, and file dealing with.

Lifecycle And Navigation











Occasion Description
onCurrentPageChanging Runs earlier than the present web page modifications and might management navigation.
onCurrentPageChanged Runs after the present web page modifications.
onCompleting Runs earlier than completion and might block or delay completion.
onComplete Runs after the survey completes and exposes the ultimate response information.
onPartialSend Runs when partial survey information is able to be despatched.
onTimerTick Runs on survey timer ticks.
onTriggerExecuted Runs after a conditional set off executes.

Values And Validation












Occasion Description
onValueChanging Runs earlier than a survey response worth modifications.
onValueChanged Runs after a survey response worth modifications.
onVariableChanged Runs after a customized survey variable modifications.
onPropertyChanged Runs after a property on the survey mannequin modifications.
onValidateQuestion Runs when a query is validated and might add customized errors.
onValidatePage Runs when a web page is validated and might add customized errors.
onServerValidateQuestions Runs when survey values want server-side validation earlier than navigation or completion.
onCheckAnswerCorrect Runs in the course of the quiz reply correctness examine.

Rendering And Decisions













Occasion Description
onAfterRenderSurvey Runs after the survey is rendered.
onAfterRenderQuestion Runs after a query is rendered.
onAfterRenderQuestionInput Runs after a query enter ingredient is rendered.
onFocusInQuestion Runs when focus enters a query.
onResize Runs when SurveyJS processes a resize operation for the rendered survey.
onChoicesLazyLoad Runs when a choice-based query requests one other batch of decisions.
onChoicesLoaded Runs after decisions are loaded for a choice-based query.
onChoicesSearch Runs when a respondent searches inside a alternative listing.
onCreateCustomChoiceItem Runs when SurveyJS creates a customized alternative merchandise entered by a respondent.

Survey Construction











Occasion Description
onQuestionAdded Runs after a query is added.
onQuestionRemoved Runs after a query is eliminated.
onQuestionVisibleChanged Runs after query visibility modifications.
onPanelAdded Runs after a panel is added.
onPanelRemoved Runs after a panel is eliminated.
onPageAdded Runs after a web page is added to the survey.
onPageVisibleChanged Runs after web page visibility modifications.

Matrix And Dynamic Panel










Occasion Description
onMatrixRowAdded Runs after a dynamic matrix row is added.
onMatrixRowRemoved Runs after a dynamic matrix row is eliminated.
onMatrixCellValueChanged Runs after a matrix cell worth modifications.
onDynamicPanelAdded Runs after a Dynamic Panel merchandise is added.
onDynamicPanelRemoved Runs after a Dynamic Panel merchandise is eliminated.
onDynamicPanelValueChanged Runs after a worth inside a Dynamic Panel merchandise modifications.

Recordsdata And Content material Customization












Occasion Description
onUploadFiles Runs when File query information have to be uploaded.
onDownloadFile Runs when a saved File query merchandise must be downloaded.
onClearFiles Runs when File query information have to be cleared.
onProcessHtml Runs whereas SurveyJS processes HTML content material earlier than show.
onTextMarkdown Runs when SurveyJS converts Markdown textual content for show.
onUpdateQuestionCssClasses Runs when SurveyJS builds CSS courses for a query.
onUpdatePanelCssClasses Runs when SurveyJS builds CSS courses for a panel.
onUpdatePageCssClasses Runs when SurveyJS builds CSS courses for a web page.

Occasion Examples

React To A Response Change

onValueChanged runs after SurveyJS shops a brand new response worth.


survey.onValueChanged.add(perform (sender, choices) {
  console.log("Up to date subject:", choices.title);
  console.log("Present information:", sender.information);
});

Run Customized Validation

onValidateQuestion can add validation errors to a query in the course of the regular validation cycle.


survey.onValidateQuestion.add(perform (sender, choices) {
  if (choices.title === "employee_id" && !/^EMP-d{4}$/.check(choices.worth || "")) {
    choices.error = "Use the format EMP-1234.";
  }
});

Customise Query CSS Lessons

onUpdateQuestionCssClasses can change courses earlier than a query renders.


survey.onUpdateQuestionCssClasses.add(perform (sender, choices) {
  if (choices.query.title === "satisfaction") {
    choices.cssClasses.root += " satisfaction-question";
  }
});

Package deal And Compatibility Notes

  • survey-core comprises the mannequin and logic. A browser web page additionally wants survey-js-ui to render the shape.
  • jQuery is elective. Present jQuery code can use $("#surveyContainer").Survey({ mannequin: survey }) after the browser renderer masses.
  • The separate survey-jquery bundle is a legacy 1.x integration and declares jQuery 1.12.4 or newer as a dependency.
  • progressBarShowPageTitles stays as a deprecated property. Use progressBarShowNavigationText for brand new implementations.
  • A number of survey cases ought to set distinct elementIdPrefix values earlier than rendering to keep away from duplicate generated ingredient IDs.
  • Theme customization makes use of theme objects and --sjs2- design tokens.

Alternate options & Associated Sources

Changelog

v3.2.5 (2026-11-12)


This superior jQuery plugin is developed by surveyjs. For extra Superior Usages, please examine the demo web page or go to the official web site.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments