Returns startPage
if the survey currently displays a start page; otherwise, returns currentPage
.
Adds an element to the survey layout.
This method accepts an object with the following layout element properties:
id
: string
| "timerpanel"
| "progress-buttons"
| "progress-questions"
| "progress-pages"
| "progress-correctquestions"
| "progress-requiredquestions"
| "toc-navigation"
| "buttons-navigation"
A layout element identifier. You can use possible values to access and relocate or customize predefined layout elements.
container
: "header"
| "footer"
| "left"
| "right"
| "contentTop"
| "contentBottom"
A layout container that holds the element. If you want to display the element within multiple containers, set this property to an array of possible values.
component
: string
The name of the component that renders the layout element.
data
: any
Data passed as props to component
.
A layout element configuration.
The configuration of the previous layout element with the same id
.
Adds a custom navigation item similar to the Previous Page, Next Page, and Complete buttons. Accepts an object described in the IAction help section.
val, type: IAction
Creates a new page and adds it to the survey.
If you want to switch a survey to the newly added page, assign its index to the currentPageNo
property or assign the entire page to the currentPage
property.
A page name. If you do not specify this parameter, it will be generated automatically.
index, type: number ,An index at which to insert the page. If you do not specify this parameter, the page will be added to the end.
The created and added page.
Adds an existing page to the survey.
A page to add.
index, type: number ,An index at which to insert the page. If you do not specify this parameter, the page will be added to the end.
Applies a specified theme to the survey.
An ITheme
object with theme settings.
Specifies whether to complete the survey automatically after a user answers all questions on the last page. Applies only if the autoAdvanceEnabled
property is true
.
Default value: true
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies whether the survey switches to the next page automatically after a user answers all questions on the current page.
Default value: false
If you enable this property, the survey is also completed automatically. Set the autoAdvanceAllowComplete
property to false
if you want to disable this behavior.
If any of the following questions is answered last, the survey does not switch to the next page: Checkboxes, Yes/No (Boolean) (rendered as Checkbox), Long Text, Signature, Image Picker (with Multi Select), File Upload, Single-Select Matrix (not all rows are answered), Dynamic Matrix, Dynamic Panel.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies whether to focus the first question with a validation error on the current page.
Default value: true
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies whether to focus the first question on the page on survey startup or when users switch between pages.
Default value: false
in v1.9.114 and later, true
in earlier versions
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
An image to display in the background of the survey or form. Accepts a base64 or URL string value.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
A value from 0 to 1 that specifies how transparent the background image should be: 0 makes the image completely transparent, and 1 makes it opaque.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
An array of calculated values.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies when the survey validates answers.
Possible values:
"onNextPage"
(default) - Triggers validation before the survey is switched to the next page or completed."onValueChanged"
- Triggers validation each time a question value is changed. View Demo"onComplete"
- Triggers validation when a user clicks the Complete button. If previous pages contain errors, the survey switches to the page with the first error.In SurveyJS Form Library v1.12.5 and earlier, the
"onValueChanged"
mode doesn't work with date input fields because of the way browsers process date values. In most browsers, the value is considered changed as soon as a user starts entering the date in a text input field. This means that a user may only enter the day without having the chance to enter the month and year before validation is triggered. For this reason, date input fields are validated before the survey is switched to the next page or completed. Starting with v1.12.6,"onValueChanged"
works for date input fields as well as for input fields of other types.
Refer to the following help topic for more information: Data Validation.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Opens a dialog window for users to select files.
A callback function that you can use to process selected files. Accepts an array of JavaScript File objects.
context, type: { element: Base; item?: any; elementType?: string; propertyName?: string; }
Resets the survey state
and, optionally, data
. If state
is "completed"
, it becomes "running"
.
(Optional) Specifies whether to clear survey data. Default value: true
.
(Optional) Specifies whether to switch the survey to the first page. Default value: true
.
Specifies whether to remove disabled choices from the value in Dropdown, Checkboxes, and Radio Button Group questions.
Default value: false
This property cannot be specified in the survey JSON schema. Use dot notation to specify it.
Removes values that cannot be assigned to a question, for example, choices unlisted in the choices
array.
Call this method after you assign new question values in code to ensure that they are acceptable.
This method does not remove values that fail validation. Call the
validate()
method to validate newly assigned values.
Pass true
to remove values that do not correspond to any question or calculated value.
Specifies when to remove values of invisible questions from survey results.
Possible values:
"onComplete"
(default) - Clears invisible question values when the survey is complete."onHidden"
- Clears a question value when the question becomes invisible. If the question is invisible initially, its value is removed on survey completion."onHiddenContainer"
- Clears a question value when the question or its containter (page or panel) becomes invisible. If the question is invisible initially, its value is removed on survey completion."none"
- Keeps invisible values in survey results.true
- Equivalent to "onComplete"
.false
- Equivalent to "none"
.This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Deletes an answer from survey results.
An object property that stores the answer to delete. Pass a question's valueName
or name
.
Creates a new object that has the same type and properties as the current SurveyJS object.
HTML content displayed to a user who has completed the survey before. To identify such users, the survey uses a cookie name.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
An array of objects that allows you to specify different HTML content for the complete page.
Each object should include the expression
and html
properties. When expression
evaluates to true
, the survey uses the corresponding HTML markup instead of completedHtml
. Refer to the following help topic for more information about expressions: Expressions.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Gets or sets a caption for the Complete button.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
A cookie name used to save information about survey completion.
When this property has a value, the survey creates a cookie with the specified name on completion. This cookie helps ensure that users do not pass the same survey twice. On the second run, they will see the Completed Before page.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Creates and returns a new page but does not add it to the survey.
Call the addPage(page)
method to add the created page to the survey later or the addNewPage(name, index)
method to create and add a page to the survey.
name, type: string
Gets or sets an object in which keys are UI elements and values are CSS classes applied to them.
Gets or sets the current page, panel, or question (depends on the questionsOnPageMode
value).
The following table illustrates the dependency between questionsOnPageMode
values and the types of survey elements that the currentElement
property can contain:
questionsOnPageMode
Survey element "standard"
or "singlePage"
Page "questionPerPage"
Question or Panel "inputPerPage"
Question
Specifies the current page, panel, or question (depends on the questionsOnPageMode
value) using its name
.
The following table illustrates the dependency between questionsOnPageMode
values and the types of survey elements that the currentElementName
property can specify:
questionsOnPageMode
Survey element "standard"
or "singlePage"
Page "questionPerPage"
Question or Panel "inputPerPage"
Question
Gets or sets the current page.
If you want to change the current page, set this property to a PageModel
object. You can get this object in different ways. For example, you can call the getPageByName()
method to obtain a PageModel
object with a specific name:
survey.currentPage = survey.getPageByName("my-page-name");
Alternative ways to change the current page are listed below:
currentPageNo
property to the index of the required page.currentElementName
property.currentElement
property.The currentPage
property does not return the start page even if it is current. Use the activePage
property instead if your survey contains a start page.
A zero-based index of the current page in the visiblePages
array.
Gets or sets an object with survey results. You can set this property with an object of the following structure:
{
question1Name: question1Value,
question2Name: question2Value,
// ...
}
When you set the data
property in code, the new object overrides the old object that may contain default question values and entered data. If you want to merge the new and old objects, call the mergeData(newDataObj)
method.
If you assign a new object while a respondent takes the survey, set the currentPageNo
property to 0 to start the survey from the beginning. This will also cause the survey to re-evaluate the visibleIf
, enableIf
, and other expressions.
Disposes of the survey model.
Call this method to release resources if your application contains multiple survey models or if you re-create a survey model at runtime.
Completes the survey.
When you call this method, Form Library performs the following actions:
cookieName
property is set.state
to "completed"
.onComplete
event.navigateToUrl
or navigateToUrlOnCondition
property.The doComplete()
method completes the survey regardless of validation errors and the current page. If you need to ensure that survey results are valid and full, call the completeLastPage()
method instead.
For internal use.
completeTrigger, type: Trigger ,For internal use.
false
if survey completion is cancelled within the onCompleting
event handler; otherwise, true
.
Gets or sets a caption for the Edit button displayed when the survey shows a preview of given answers.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
A message that is displayed when a survey does not contain visible pages or questions.
Gets or sets a Boolean value that specifies whether the first page is a start page.
Refer to the following help topic for more information: Start Page.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Focuses a question with a specified name. Switches the current page if needed.
A question name.
false
if the survey does not contain a question with the specified name or this question is hidden; otherwise, true
.
Assigns a new JSON schema to the current survey element.
The JSON schema should contain only serializable properties of this survey element. Event handlers and properties that do not belong to the survey element are ignored.
A JSON schema that you want to apply to the current survey element.
options, type: ILoadFromJSONOptions ,An object with configuration options.
options.validatePropertyValues, type: boolean ,Pass true
if you want to validate property values. Use the jsonErrors
array to access validation errors.
Returns a list of all panels in the survey.
A Boolean value that specifies whether to include only visible panels.
includeDesignTime, type: boolean ,For internal use.
An array of panels.
Returns a list of all questions in the survey.
A Boolean value that specifies whether to include only visible questions.
includeDesignTime, type: boolean ,For internal use.
includeNested, type: boolean ,A Boolean value that specifies whether to include nested questions, such as questions within matrix cells.
An array of questions.
Returns an object with survey results.
If you want to get a survey results object that mirrors the survey structure, call the getData()
method with an object that has the includePages
and includePanels
properties enabled. Without this object, the getData()
method returns the data
property value.
import { Model } from "survey-core";
const surveyJson = { ... };
const survey = new Model(surveyJson);
survey.getData({ includePages: true, includePanels: true });
options, type: { includePages?: boolean; includePanels?: boolean; }
Returns a page, panel, or question with a specified name
.
A survey element name.
A survey element with the specified name.
Returns the number of incorrect answers in a quiz.
For more information about quizzes, refer to the following tutorial: Create a Quiz.
The number of incorrect answers in a quiz.
Returns a page to which a specified survey element (question or panel) belongs.
A question or panel instance.
Returns a page with a specified name.
A page name.
A page with the specified name.
Returns a page to which a specified question belongs.
A question instance.
Returns a panel with a specified name
.
A panel name.
caseInsensitive, type: boolean
A panel with the specified name.
Returns survey results as an array of objects in which the question name, title, value, and other parameters are stored as individual properties.
If a question can have more than one value (Matrix, Multiple Text), its object enables the isNode
flag and stores information about these values in the data
property. Refer to the following help topic for more information: Access Full Survey Results.
If you want to skip empty answers, pass an object with the includeEmpty
property set to false
.
options, type: IPlainDataOptions
Returns a JsonObjectProperty
object with metadata about a serializable property that belongs to the current SurveyJS object.
If the property is not found, this method returns null
.
A property name.
Returns the value of a property with a specified name.
If the property is not found or does not have a value, this method returns either undefined
, defaultValue
specified in the property configuration, or a value passed as the defaultValue
parameter.
A property name.
defaultValue, type: any ,(Optional) A value to return if the property is not found or does not have a value.
calcFunc, type: () => any
Returns a question with a specified name
.
A question name.
caseInsensitive, type: boolean
A question with the specified name.
Returns a question with a specified valueName
.
Since
valueName
does not have to be unique, multiple questions can have the samevalueName
value. In this case, thegetQuestionByValueName()
method returns the first such question. If you need to get all questions with the samevalueName
, call thegetQuestionsByValueName()
method.
A question's valueName
property value.
caseInsensitive, type: boolean
A question with a specified valueName
.
Returns all questions with a specified valueName
. If a question's valueName
is undefined, its name
property is used.
A question's valueName
property value.
caseInsensitive, type: boolean
An array of questions with a specified valueName
.
Returns the number of quiz questions. A question counts if it is visible, has an input field, and specifies correctAnswer
.
This number may be different from getQuizQuestions().length
because certain question types (for instance, matrix-like types) include more than one question.
For more information about quizzes, refer to the following tutorial: Create a Quiz.
The number of quiz questions.
Returns an array of quiz questions. A question counts if it is visible, has an input field, and specifies correctAnswer
.
For more information about quizzes, refer to the following tutorial: Create a Quiz.
An array of quiz questions.
resultId, type: string
questionName, type: string
Returns the object type as it is used in the JSON schema.
Returns a value (answer) for a question with a specified name
.
A question name.
A question value (answer).
Enables the grid layout, which structures form elements using a column-based system.
Default value: false
Specify the gridLayoutColumns
property for pages and panels to configure layout columns. Set the colSpan
property for an individual question or panel to adjust how many columns this survey element spans.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Indicates whether the browser has a cookie with a specified cookieName
. If this property's value is true
, the respondent has passed the survey previously.
Returns true
if the current page does not contain errors.
Use this method to find out if the current object is of a given typeName
or inherited from it.
One of the values listed in the getType() description.
true
if the current object is of a given typeName
or inherited from it.
Indicates whether the current page is the first page.
If the survey displays the start page, this property contains
false
. Use theisStartPageActive
property to find out whether the start page is currently displayed.
Indicates whether the current page is the last page.
Returns true
if the object configuration is being loaded from JSON.
Returns true
if the survey element is a page.
This property returns false
for PageModel
objects in the following cases:
SurveyModel
's questionsOnPageMode
is set to "singlePage"
.In those cases, the survey creates an internal PageModel
object to show all questions on one page, and all regular pages become panels.
Returns true
if the survey element is a panel or acts as one.
This property returns true
for PageModel
objects in the following cases:
SurveyModel
's questionsOnPageMode
is set to "singlePage"
.In those cases, the survey creates an internal PageModel
object to show all questions on one page, and all regular pages become panels.
Returns true
if the survey element is a question.
A Boolean value that indicates whether the start page is currently displayed.
Returns true
if the element is a survey.
Returns true
if a passed value
is an empty string, array, or object or if it equals to undefined
or null
.
A value to be checked.
trimString, type: boolean ,(Optional) When this parameter is true
, the method ignores whitespace characters at the beginning and end of a string value. Pass false
to disable this functionality.
Specifies whether to keep values that cannot be assigned to questions, for example, choices unlisted in the choices
array.
This property cannot be specified in the survey JSON schema. Use dot notation to specify it.
Specifies whether to enable lazy rendering.
In default mode, a survey renders the entire current page. With lazy rendering, the survey renders the page gradually as a user scrolls it. This helps reduce survey startup time and optimizes large surveys for low-end devices.
Default value: false
HTML content displayed while a survey JSON schema is being loaded.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
surveyId, type: string
clientId, type: string
An image URL or a Base64-encoded image to use as a survey logo.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies how to resize a logo to fit it into its container.
Possible values:
"contain"
(default)"cover"
"fill"
"none"
Refer to the object-fit
CSS property description for information on the possible values.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
A logo position relative to the survey title.
Possible values:
"left"
(default) - Places the logo to the left of the survey title."right"
- Places the logo to the right of the survey title."none"
- Hides the logo.This property is stored in the survey JSON definition and can be edited in the Survey Creator.
A logo width in CSS-accepted values.
Default value: auto
(the width is calculated automatically based on the logoHeight
value to keep the original aspect ratio)
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies which part of a matrix row responds to a drag gesture in Dynamic Matrix questions.
Possible values:
"entireItem"
(default) - Users can use the entire matrix row as a drag handle."icon"
- Users can only use a drag icon as a drag handle.This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies the maximum text length in textual questions (Single-Line Input, Long Text, Multiple Textboxes), measured in characters.
Default value: 0 (unlimited)
You can override this setting for individual questions if you specify their maxLength
property.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Merges a specified data object with the object from the data
property.
Refer to the following help topic for more information: Populate Form Fields | Multiple Question Values.
A data object to merge. It should have the following structure: { questionName: questionValue, ... }
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
A URL to which respondents should be navigated after survey completion.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
An array of objects that allows you to navigate respondents to different URLs after survey completion.
Each object should include the expression
and url
properties. When expression
evaluates to true
, the survey navigates to the corresponding url
. Refer to the following help topic for more information about expressions: Expressions.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Gets or sets the position of the Start, Next, Previous, and Complete navigation buttons. Applies only if the showNavigationButtons
property is true
.
Possible values:
"bottom"
(default) - Displays the navigation buttons below survey content."top"
- Displays the navigation buttons above survey content."topBottom"
- Displays the navigation buttons above and below survey content.This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Switches the survey to the next page.
This method returns a Boolean value that indicates whether the page was successfully switched. false
is returned if the current page is the last page or if it contains validation errors.
true
if the page was successfully switched; false
otherwise.
Displays a toast notification with a specified message.
Depending on the type
argument, a survey can display the following notification types:
A message to display.
type, type: string ,A notification type: "info"
(default), "success"
, or "error"
.
For internal use.
An event that is raised after a cell in a Multi-Select Matrix or Dynamic Matrix is rendered to the DOM.
Parameters:
sender
: SurveyModel
options.question
: Question
options.htmlElement
: any
options.cell
: MatrixDropdownCell
options.cellQuestion
: Question
options.row
: MatrixDropdownRowModelBase
options.column
: MatrixDropdownColumn | MatrixDropdownCell
An event that is raised after a page is rendered to the DOM. Use it to modify page markup.
Parameters:
sender
: SurveyModel
options.htmlElement
: any
options.page
: PageModel
An event that is raised after a panel is rendered to the DOM. Use it to modify panel markup.
Parameters:
sender
: SurveyModel
options.htmlElement
: any
options.panel
: PanelModel
This event is raised for static Panels as well as panels within a Dynamic Panel.
An event that is raised after a question is rendered to the DOM. Use it to modify question markup.
Parameters:
sender
: SurveyModel
options.question
: Question
options.htmlElement
: any
An event that is raised after a question with a single input field is rendered to the DOM. Use it to modify question markup.
Parameters:
sender
: SurveyModel
options.question
: Question
options.htmlElement
: any
This event is not raised for questions without input fields (HTML, Image) or questions with multiple input fields (Matrix, Multiple Text).
An event that is raised after the survey is rendered to the DOM. Use this event to modify survey markup.
Parameters:
sender
: SurveyModel
options.htmlElement
: any
An event that is raised to define whether a question answer is correct. Applies only to quiz surveys.
Parameters:
sender
: SurveyModel
options.question
: Question
options.result
: boolean
true
) or incorrect (false
). Use the options.question.value
and options.question.correctAnswer
properties to check the answer.options.correctAnswerCount
: number
options.incorrectAnswerCount
: number
Use this event to load choice items in Dropdown and Tag Box questions on demand.
This event is raised only for those questions that have the choicesLazyLoadEnabled
property set to true
.
Parameters:
sender
: SurveyModel
options.question
: Question
options.setItems
: (items: (string | { value: any; text?: string; imageLink?: string; customProperty?: any; })[], totalCount: number) => void
choices
property description. If their structure is different, map their properties to bring them to the required structure.options.filter
: string
options.take
: number
choicesLazyLoadPageSize
property to change this number.options.skip
: number
An event that is raised after choices are loaded from a server but before they are assigned to a choice-based question, such as Dropdown or Checkboxes. Handle this event if you need to modify the loaded choices.
Parameters:
sender
: SurveyModel
options.question
: Question
options.serverResult
: any
options.choices
: ItemValue[]
An event that is raised each time a search string in a Dropdown or Tag Box question changes. Use this event to implement custom filtering of choice options.
Parameters:
sender
: SurveyModel
options.question
: Question
options.filter
: string
options.choices
: ItemValue[]
options.filteredChoices
: ItemValue[]
options.filter
to the options.choices
array and assign the result to this parameter.An event that is raised when users clear files in a File Upload question or clear signature in a Signature Pad question. Use this event to delete files from your server.
Parameters:
sender
: SurveyModel
options.question
: QuestionFileModel | QuestionSignaturePadModel
options.name
: string
options.callback
: (status: string, data?: any) => any
"success"
or "error"
as the first argument to indicate the operation status. As the second argument, you can pass deleted files' data (options.value
) if file deletion was successful or an error message if file deletion failed.options.fileName
: string
null
, all files should be deleted.options.value
: any
value
that contains metadata about uploaded files.An event that is raised after the survey is completed. Use this event to send survey results to the server.
Parameters:
sender
: SurveyModel
options.isCompleteOnTrigger
: boolean
true
if survey completion is caused by a "complete" trigger.options.completeTrigger
: Trigger
options.isCompleteOnTrigger
is true
.options.clearSaveMessages
: (test?: string) => void
options.showSaveSuccess
: (text?: string) => void
text
parameter to display a custom message.options.showSaveError
: (text?: string) => void
text
parameter to display a custom error message.options.showSaveInProgress
: (text?: string) => void
text
parameter to display a custom message.For an example of how to use the methods described above, refer to the following help topic: Store Survey Results in Your Own Database.
Do not disable the
showCompletePage
property if you call one of theoptions.showSave...
methods. This is required because the UI that indicates data saving progress is integrated into the complete page. If you hide the complete page, the UI also becomes invisible.
An event that is raised before the survey is completed. Use this event to prevent survey completion.
Parameters:
sender
: SurveyModel
options.isCompleteOnTrigger
: boolean
true
if survey completion is caused by a "complete" trigger.options.completeTrigger
: Trigger
options.isCompleteOnTrigger
is true
.options.allow
: boolean
false
if you want to prevent survey completion.An event that is raised when users add a custom choice option to a Single- or Multi-Select Dropdown question. Handle this event to save the choice option in a data storage.
Parameters:
sender
: SurveyModel
options.question
: QuestionSelectBase
options.item
: ItemValue
options.item.value
and options.item.text
properties.options.allow
: boolean
false
if you want to prevent the item from being added.To let users add their own choice options, enable the allowCustomChoices
property for individual dropdown questions.
An event that is raised after the current page is switched.
Parameters:
sender
: SurveyModel
options.isPrevPage
: boolean
true
if the respondent is switching to the previous page.options.isNextPage
: boolean
true
if the respondent is switching to the next page.options.isGoingBackward
: boolean
true
if the respondent is going backward, that is, newCurrentPage
or newCurrentQuestion
is earlier in the survey than oldCurrentPage
or oldCurrentQuestion
.options.isGoingForward
: boolean
true
if the respondent is going forward along the survey.options.isAfterPreview
: boolean
true
if the respondent is switching from the preview page.options.newCurrentPage
: PageModel
options.oldCurrentPage
: PageModel
oldCurrentPage
and newCurrentPage
parameters may contain the same PageModel
instance. This is because the survey doesn't create artificial pages to display only one question per page. If both the previous and current questions belong to the same page in the survey JSON schema, they have the same parent PageModel
instance.options.oldCurrentQuestion
: Question
options.newCurrentQuestion
: Question
An event that is raised before the current page is switched.
Parameters:
sender
: SurveyModel
options.isPrevPage
: boolean
true
if the respondent is switching to the previous page.options.isNextPage
: boolean
true
if the respondent is switching to the next page.options.isGoingBackward
: boolean
true
if the respondent is going backward, that is, newCurrentPage
or newCurrentQuestion
is earlier in the survey than oldCurrentPage
or oldCurrentQuestion
.options.isGoingForward
: boolean
true
if the respondent is going forward along the survey.options.isAfterPreview
: boolean
true
if the respondent is switching from the preview page.options.newCurrentPage
: PageModel
options.oldCurrentPage
: PageModel
oldCurrentPage
and newCurrentPage
parameters may contain the same PageModel
instance. This is because the survey doesn't create artificial pages to display only one question per page. If both the previous and current questions belong to the same page in the survey JSON schema, they have the same parent PageModel
instance.options.oldCurrentQuestion
: Question
options.newCurrentQuestion
: Question
options.allow
: boolean
false
if you do not want to switch the current page.An event that is raised when a File Upload question starts to download a file. Use this event to implement file preview when your server stores only file names.
Parameters:
sender
: SurveyModel
options.question
: QuestionFileModel | QuestionSignaturePadModel
options.name
: string
options.callback
: (status: string, data?: any) => any
"success"
or "error"
as the first argument to indicate the operation status. As the second argument, you can pass the downloaded file's data as a Base64 string if file download was successful or an error message if file download failed.options.fileValue
: any
value
that contains metadata about uploaded files.options.content
: any
An event that is raised when users drag and drop survey elements while designing the survey in Survey Creator. Use this event to control drag and drop operations.
Parameters:
sender
: SurveyModel
options.draggedElement
: IElement
options.fromElement
: IPanel
draggedElement
is being dragged. This parameter is null
if draggedElement
is being dragged from the Toolbox.options.toElement
: IElement
draggedElement
is being dragged.options.insertBefore
: IElement
null
if the parent container (page or panel) has no elements or if the target element will be placed below all other elements within the container.options.insertAfter
: IElement
draggedElement
will be placed. This parameter is null
if the parent container (page or panel) has no elements or if draggedElement
will be placed above all other elements within the container.options.parent
: ISurveyElement
draggedElement
will be placed.options.allow
: boolean
false
if you want to cancel the drag and drop operation.An event that is raised after a new panel is added to a Dynamic Panel question.
Parameters:
sender
: SurveyModel
options.question
: QuestionPanelDynamicModel
options.panel
: PanelModel
options.panelIndex
: number
An event that is raised after the current panel is changed in a Dynamic Panel question.
Parameters:
sender
: SurveyModel
options.question
: QuestionPanelDynamicModel
options.panel
: PanelModel
options.visiblePanelIndex
: number
visiblePanels
array of the Dynamic Panel.An event that is raised after a panel is deleted from a Dynamic Panel question.
Parameters:
sender
: SurveyModel
options.question
: QuestionPanelDynamicModel
options.panel
: PanelModel
options.panelIndex
: number
An event that is raised before a panel is deleted from a Dynamic Panel question. Use this event to cancel the deletion.
Parameters:
sender
: SurveyModel
options.question
: QuestionPanelDynamicModel
options.panel
: PanelModel
options.panelIndex
: number
options.allow
: boolean
false
if you want to cancel panel deletion.An event that is raised after a value is changed in a panel within a Dynamic Panel question.
Parameters:
sender
: SurveyModel
options.question
: QuestionPanelDynamicModel
options.panelData
: { [index: string]: any; }
options.panelIndex
: number
options.name
: string
options.panel
: PanelModel
options.value
: any
An event that is raised before a value is changed in a panel within a Dynamic Panel question.
Parameters:
sender
: SurveyModel
options.question
: QuestionPanelDynamicModel
options.panelData
: { [index: string]: any; }
options.panelIndex
: number
options.name
: string
options.panel
: PanelModel
options.value
: any
options.oldValue
: any
An event that is raised when an element within a panel gets focus.
Parameters:
sender
: SurveyModel
options.panel
: PanelModel
An event that is raised when an element (input field, checkbox, radio button) within a question gets focus.
Parameters:
sender
: SurveyModel
options.question
: Question
Use this event to load a display text for the default choice item in Dropdown and Tag Box questions.
If you load choices from a server (use choicesByUrl
or onChoicesLazyLoad
), display texts become available only when data is loaded, which does not happen until a user opens the drop-down menu. However, a display text for a default choice item is required before that. In this case, you can load data individually for the default item within the onGetChoiceDisplayValue
event handler.
Parameters:
sender
: SurveyModel
options.question
: Question
options.setItems
: (displayValues: string[], ...customValues: IValueItemCustomPropValues[]) => void
options.values
: any[]
An event that is raised before a Dynamic Panel renders tab titles. Use this event to change individual tab titles.
Parameters:
sender
: SurveyModel
options.question
: QuestionPanelDynamicModel
options.panel
: PanelModel
options.visiblePanelIndex
: number
visiblePanels
array of the Dynamic Panel.options.title
: string
An event that is raised before an Expression question displays a value. Use this event to override the display value.
Parameters:
sender
: SurveyModel
options.question
: Question
options.displayValue
: any
options.value
: any
An event that allows you to add, delete, or modify actions in rows of a Dynamic Matrix.
Parameters:
sender
: SurveyModel
options.question
: Question
options.actions
: IAction[]
options.row
: MatrixDropdownRowModelBase
An event that is raised before the survey calculates a page number. Handle this event to modify page numbers.
This event is raised only if the showPageNumbers
property is enabled.
Parameters:
sender
: SurveyModel
options.page
: PageModel
options.number
: string
"1. "
, "2. "
, etc. You can change this parameter's value.An event that allows you to add, delete, or modify actions in a page title.
Parameters:
sender
: SurveyModel
options.page
: PageModel
options.actions
: IAction[]
An event that is raised before the survey calculates a panel number. Handle this event to modify panel numbers.
This event is raised only for the panels with a specified title and visible number.
Parameters:
sender
: SurveyModel
options.panel
: PanelModel
options.number
: string
"1. "
, "2. "
, etc. You can change this parameter's value.An event that allows you to add, delete, or modify actions in a panel title.
Parameters:
sender
: SurveyModel
options.panel
: PanelModel
options.actions
: IAction[]
An event that is raised before the survey displays progress text. Handle this event to change the progress text in code.
Parameters:
sender
: SurveyModel
options.questionCount
: number
options.answeredQuestionCount
: number
options.requiredQuestionCount
: number
options.requiredAnsweredQuestionCount
: number
options.text
: string
Use this event to change a question's display text.
Parameters:
sender
: SurveyModel
options.question
: Question
options.displayValue
: any
An event that is raised before the survey calculates a question number. Handle this event to modify question numbers.
Parameters:
sender
: SurveyModel
options.question
: Question
options.number
: string
visibleIndex
and survey's questionStartIndex
properties. You can change this parameter's value.If you want to hide question numbers, disable the showQuestionNumbers
property.
An event that is raised before the survey displays a question title. Handle this event to modify question titles.
Parameters:
sender
: SurveyModel
options.question
: Question
options.title
: string
title
or name
property. You can change this parameter's value.If you want to modify question numbers, handle the onGetQuestionNumber
event.
An event that allows you to add, delete, or modify actions in a question title.
Parameters:
sender
: SurveyModel
options.question
: Question
options.actions
: IAction[]
An event that is raised when the survey applies HTML tags to a survey, page, panel, and question title. Handle this event to change the HTML tag of individual titles.
Parameters:
sender
: SurveyModel
options.element
: Base
options.tagName
: string
"div"
). You can change this parameter's value.If you want to specify HTML tags for all titles, use the titleTags
object in global settings.
An event that is raised when an ItemValue
property is changed.
Parameters:
sender
: this
ItemValue
objects.options.obj
: ItemValue
ItemValue
object.options.propertyName
: string
ItemValue
objects is assigned (for example, "choices"
or "rows"
).options.name
: "text"
| "value"
options.newValue
: any
An event that is raised after a cell in a Multi-Select Matrix or Dynamic Matrix is created.
Parameters:
sender
: SurveyModel
options.question
: QuestionMatrixDropdownModelBase
options.column
: MatrixDropdownColumn
options.columnName
: string
options.row
: MatrixDropdownRowModelBase
options.rowValue
: any
options.rowValue["columnName"]
options.cell
: MatrixDropdownCell
options.cellQuestion
: Question
An event that is raised before a cell in a Multi-Select Matrix or Dynamic Matrix is created. Use this event to change the type of individual matrix cells.
Parameters:
sender
: SurveyModel
options.question
: QuestionMatrixDropdownModelBase
options.column
: MatrixDropdownColumn
options.columnName
: string
options.row
: MatrixDropdownRowModelBase
options.rowValue
: any
options.rowValue["columnName"]
options.cellType
: string
cellType
documentation.An event that is raised for Multi-Select Matrix and Dynamic Matrix questions when they validate a cell value. Use this event to display a custom error message based on a condition.
Parameters:
sender
: SurveyModel
options.question
: QuestionMatrixDropdownModelBase
options.row
: MatrixDropdownRowModelBase
options.column
: MatrixDropdownColumn
options.columnName
: string
options.cellQuestion
: Question
options.getCellQuestion
: (columnName: string) => Question
options.value
: any
options.error
: string
undefined
.An event that is raised after a cell value is changed in a Multi-Select Matrix or Dynamic Matrix.
Parameters:
sender
: SurveyModel
options.question
: QuestionMatrixDropdownModelBase
options.row
: MatrixDropdownRowModelBase
options.column
: MatrixDropdownColumn
options.columnName
: string
options.cellQuestion
: Question
options.getCellQuestion
: (columnName: string) => Question
options.value
: any
An event that is raised before a cell value is changed in a Multi-Select Matrix or Dynamic Matrix. Use this event to change the cell value.
Parameters:
sender
: SurveyModel
options.question
: QuestionMatrixDropdownModelBase
options.row
: MatrixDropdownRowModelBase
options.column
: MatrixDropdownColumn
options.columnName
: string
options.cellQuestion
: Question
options.getCellQuestion
: (columnName: string) => Question
options.value
: any
options.oldValue
: any
An event that is raised after a new column is added to a Multi-Select Matrix or Dynamic Matrix.
Parameters:
sender
: SurveyModel
options.question
: Question
options.column
: any
An event that is raised after the visibility of an expandable detail section is changed. This event can be raised for Multi-Select and Dynamic Matrix questions.
Parameters:
sender
: SurveyModel
options.question
: QuestionMatrixDropdownModelBase
options.row
: MatrixDropdownRowModelBase
options.rowIndex
: number
options.detailPanel
: PanelModel
options.visible
: boolean
An event that is raised before rendering the Remove button in a row of a Dynamic Matrix. Use this event to hide the Remove button for individual matrix rows.
Parameters:
sender
: SurveyModel
options.question
: QuestionMatrixDynamicModel
options.row
: MatrixDropdownRowModelBase
options.rowIndex
: number
options.allow
: boolean
false
if you want to hide the Remove button for this row.An event that is raised after a new row is added to a Dynamic Matrix.
Parameters:
sender
: SurveyModel
options.question
: QuestionMatrixDynamicModel
options.row
: MatrixDropdownRowModelBase
An event that is raised before a new row is added to a Dynamic Matrix.
Parameters:
sender
: SurveyModel
options.question
: QuestionMatrixDynamicModel
options.allow
: boolean
false
if you do not want to add the row.An event that is raised after a row is deleted from a Dynamic Matrix.
Parameters:
sender
: SurveyModel
options.question
: QuestionMatrixDynamicModel
options.row
: MatrixDropdownRowModelBase
options.rowIndex
: number
An event that is raised before a row is deleted from a Dynamic Matrix. You can cancel row deletion and clear row data instead.
Parameters:
sender
: SurveyModel
options.question
: QuestionMatrixDynamicModel
options.row
: MatrixDropdownRowModelBase
options.row.value
property to undefined
.options.rowIndex
: number
options.allow
: boolean
false
if you want to cancel row deletion.An event that is raised on adding a new item in Multiple Text question.
Parameters:
sender
: SurveyModel
options.question
: Question
options.item
: any
An event that is raised before the survey navigates to a specified URL. Use this event to change the URL or cancel the navigation.
Parameters:
sender
: SurveyModel
options.allow
: boolean
false
if you want to cancel the navigation and show the complete page.options.url
: string
An event that is raised when a respondent opens a dialog window to select files.
Parameters:
sender
: SurveyModel
options.input
: any
options.element
: Base
options.elementType
: string
options.element
parameter.getType()
method.options.propertyName
: string
options.item
: ItemValue
options.callback
: (files: any[]) => void
An event that is raised when a new page is added to the survey.
Parameters:
sender
: SurveyModel
options.page
: PageModel
An event that is raised after page visibility is changed.
Parameters:
sender
: SurveyModel
options.visible
: boolean
options.page
: PageModel
Refer to the following help topic for information on how to implement conditional visibility: Conditional Visibility.
An event that is raised when a new panel is added to a page.
Parameters:
sender
: SurveyModel
options.panel
: PanelModel
options.page
: PanelModelBase
options.parent
: PanelModelBase
options.index
: number
options.name
: string
An event that is raised after a panel is deleted from the survey.
Parameters:
sender
: SurveyModel
options.panel
: PanelModel
options.name
: string
An event that is raised after panel visibility is changed.
Parameters:
sender
: SurveyModel
options.visible
: boolean
options.panel
: PanelModel
Refer to the following help topic for information on how to implement conditional visibility: Conditional Visibility.
An event that is raised when the survey processes dynamic texts and any text in curly brackets. Use this event, for instance, to substitute parameters in a RESTful URL with real values when you load choices by URL.
Parameters:
sender
: SurveyModel
options.name
: string
options.value
: any
An event that is raised when a property of this SurveyJS object has changed.
Parameters:
sender
: this
options.name
: string
options.newValue
: any
options.oldValue
: any
oldValue
contains the same array as newValue
does.If you need to add and remove property change event handlers dynamically, use the registerPropertyChangedHandlers
and unregisterPropertyChangedHandlers
methods instead.
An event that is raised when a new question is added to a panel or page.
Parameters:
sender
: SurveyModel
options.question
: Question
options.page
: PanelModelBase
options.parent
: PanelModelBase
options.index
: number
options.name
: string
To use this event for questions loaded from JSON, create an empty survey model, add an event handler, and only then populate the model from the JSON object:
import { Model } from "survey-core";
const surveyJson = {
// ...
};
// Create an empty model
const survey = new Model();
// Add an event handler
survey.onQuestionAdded.add((sender, options) => {
//...
});
// Load the survey JSON schema
survey.fromJSON(surveyJson);
An event that is raised when the survey creates any new object derived from Question
.
In a survey, complex elements (Dynamic Matrix, Multiple Text, and Dynamic Panel) are composed of questions. Use this event to customize any question regardless of which survey element it belongs to.
Parameters:
sender
: SurveyModel
options.question
: Question
To use this event for questions loaded from JSON, create an empty survey model, add an event handler, and only then populate the model from the JSON object:
import { Model } from "survey-core";
const surveyJson = {
// ...
};
// Create an empty model
const survey = new Model();
// Add an event handler
survey.onQuestionCreated.add((sender, options) => {
//...
});
// Load the survey JSON schema
survey.fromJSON(surveyJson);
An event that is raised after a question is deleted from the survey.
Parameters:
sender
: SurveyModel
options.question
: Question
options.name
: string
An event that is raised after question visibility is changed.
Parameters:
sender
: SurveyModel
options.question
: Question
options.visible
: boolean
options.name
: string
Refer to the following help topic for information on how to implement conditional visibility: Conditional Visibility.
An event that is raised when the survey's width or height is changed.
Parameters:
sender
: SurveyModel
options.width
: number
options.height
: number
Use this event to validate data on your server.
Parameters:
sender
: SurveyModel
options.complete
: () => void
options.errors
: { [index: string]: any; }
options.errors["questionName"] = "My error message"
.options.data
: { [index: string]: any; }
options.data["questionName"]
.An event that is raised before a choice item is displayed. Use this event to change the visibility of individual choice items in Checkboxes, Dropdown, Radio Button Group, and other similar question types.
Parameters:
sender
: SurveyModel
options.question
: Question
options.item
: ItemValue
options.visible
: boolean
false
to hide the item.An event that is raised when the survey state
changes to "running"
.
For information on event handler parameters, refer to descriptions within the interface.
An event that is raised to convert Markdown content to HTML.
Parameters:
sender
: SurveyModel
options.element
: Question | PanelModel | PageModel | SurveyModel
options.name
: string
options.item
: ItemValue
options.element
is a choice-based question, such as Dropdown or Checkboxes.options.text
: string
options.html
parameter.options.html
: string
An event that is raised before rendering a choice item in Radio Button Group, Checkboxes and Rating Scale questions. Use it to override default CSS classes applied to choice items.
Parameters:
sender
: SurveyModel
options.question
: Question
options.item
: ItemValue
options.item.value
and options.item.text
properties.options.css
: string
An event that is raised before rendering a page. Use it to override default page CSS classes.
Parameters:
sender
: SurveyModel
options.page
: PageModel
options.cssClasses
: any
{ root: "class1", button: "class2" }
. You can modify this object to apply custom CSS classes.An event that is raised before rendering a standalone panel and panels within Dynamic Panel. Use it to override default panel CSS classes.
Parameters:
sender
: SurveyModel
options.panel
: PanelModel
options.cssClasses
: any
{ root: "class1", button: "class2" }
. You can modify this object to apply custom CSS classes.An event that is raised before rendering a question. Use it to override default question CSS classes.
Parameters:
sender
: SurveyModel
options.question
: Question
options.cssClasses
: any
{ root: "class1", button: "class2" }
. You can modify this object to apply custom CSS classes.An event that is raised when a File Upload or Signature Pad question starts to upload a file. Applies only if storeDataAsText
is false
. Use this event to upload files to your server.
Parameters:
sender
: SurveyModel
options.question
: QuestionFileModel | QuestionSignaturePadModel
options.name
: string
options.callback
: (data: any, errors?: any) => any
options.files
: any[]
An event that is raised when a survey page is being validated. Use this event to add/remove/modify errors.
Parameters:
sender
: SurveyModel
options.page
: PageModel
options.questions
: Question[]
options.errors
: SurveyError[]
An event that is raised when a panel is being validated. Use this event to add/remove/modify errors or specify a custom error message.
Parameters:
sender
: SurveyModel
options.panel
: PanelModel
options.name
: string
options.error
: string
options.errors
: SurveyError[]
An event that is raised when a question value is being validated. Use this event to add/remove/modify errors or specify a custom error message.
Parameters:
sender
: SurveyModel
options.question
: Question
options.value
: any
options.name
: string
options.error
: string
options.errors
: SurveyError[]
An event that is raised after a question value is changed.
Parameters:
sender
: SurveyModel
options.question
: Question
options.name
: string
name
of the question whose value is being changed. If you use the valueName
property, this parameter contains its value.options.reason
: "trigger" | "expression"
undefined
.options.value
: any
To handle value changes in matrix cells or panels within a Dynamic Panel, use the onMatrixCellValueChanged
or onDynamicPanelValueChanged
event.
An event that is raised before a question value is changed.
Parameters:
sender
: SurveyModel
options.question
: Question
options.name
: string
name
of the question whose value is being changed. If you use the valueName
property, this parameter contains its value.options.reason
: "trigger" | "expression"
undefined
.options.value
: any
options.oldValue
: any
An event that is raised after a variable or calculated value is changed.
Parameters:
sender
: SurveyModel
options.value
: any
options.name
: string
Returns a total number of survey pages.
To get the number of visible pages, use the visiblePageCount
property.
Gets or sets a caption for the Next button.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Gets or sets a caption for the Previous button.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Returns an array of all pages in the survey.
To get an array of only visible pages, use the visiblePages
array.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies whether the preview of given answers includes all or only answered questions.
Possible values:
"allQuestions"
(default)"answeredQuestions"
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Gets or sets a caption for the Preview button.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Switches the survey to the previous page.
This method returns a Boolean value that indicates whether the page was successfully switched. false
is returned if the current page is the first page.
true
if the page was successfully switched; false
otherwise.
Returns HTML content displayed to a user who has completed the survey before. To identify such users, the survey uses a cookie name.
To specify HTML content, use the completedBeforeHtml
property.
Returns HTML content displayed while a survey JSON schema is being loaded.
To specify HTML content, use the loadingHtml
property.
Specifies whether the progress bar spans the width of the survey or that of the survey container. Applies only when the progress bar is visible and progressBarType
is "pages"
.
Possible values:
"survey"
"container"
(default)This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies the alignment of the progress bar. Applies only if the showProgressBar
property is true
.
Possible values:
"aboveHeader"
- Displays the progress bar above the survey header."belowHeader"
- Displays the progress bar below the survey header."bottom"
- Displays the progress bar below survey content."topBottom"
- Displays the progress bar above and below survey content."auto"
(default) - Displays the progress bar below the survey header if the header has a background image or color. Otherwise, the progress bar is displayed above the header.This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies whether the progress bar displays page numbers. Applies only when the progress bar is visible and progressBarType
is "pages"
.
Default value: false
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies whether the progress bar displays page titles. Applies only when the progress bar is visible and progressBarType
is "pages"
.
Default value: false
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies the type of information displayed by the progress bar. Applies only when showProgressBar
is true
.
Possible values:
"pages"
(default) - The number of completed pages."questions"
- The number of answered questions."requiredQuestions"
- The number of answered required questions."correctQuestions"
- The number of correct questions in a quiz."buttons"
- (Obsolete) Use the "pages"
property value with the progressBarShowPageTitles
property set to true
instead.When
progressBarType
is set to"pages"
, you can also enable theprogressBarShowPageNumbers
andprogressBarShowPageTitles
properties if you want to display page numbers and titles in the progress bar.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Returns text displayed by the progress bar (for instance, "Page 2 of 3" or "Answered 3/8 questions"). Handle the onGetProgressText
event to change this text.
Specifies where to display question descriptions.
Possible values:
"underTitle"
(default) - Displays descriptions under question titles."underInput"
- Displays descriptions under the interactive area.You can override this setting for individual questions if you specify their descriptionLocation
property.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies the error message position.
Possible values:
"top"
(default) - Displays error messages above questions."bottom"
- Displays error messages below questions.You can override this setting if you specify the questionErrorLocation
property for an individual page or panel or set the errorLocation
property for a specific question.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies the sort order of questions in the survey.
Possible values:
"initial"
(default) - Preserves the original order of questions."random"
- Displays questions in random order.You can override this property for individual pages and panels.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies how to distribute survey elements between pages.
Possible values:
"singlePage"
- Combines all survey pages into a single page."questionPerPage"
- Displays each question on a separate page."inputPerPage"
- Displays each input field on a separate page. Complex questions—such as Single-Select Matrix, Multi-Select Matrix, Dynamic Matrix, Dynamic Panel, and Multiple Textboxes—are split so that each input field appears on its own page. View Demo"standard"
(default) - Retains the original structure specified in the JSON schema.This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies the initial number or letter from which to start question numbering.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Gets or sets question title location relative to the input field: "top"
, "bottom"
, or "left"
.
Certain question types (Matrix, Multiple Text) do not support the
"left"
value. For them, the"top"
value is used.
You can override this setting if you specify the questionTitleLocation
property for an individual page or panel or set the titleLocation
property for a specific question.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies a pattern for question titles.
Refer to the following help topic for more information: Title Pattern.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Enables the read-only mode. If you set this property to true
, users cannot take the survey.
Default value: false
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Registers a single value change handler for one or multiple properties.
The registerPropertyChangedHandlers
and unregisterPropertyChangedHandlers
methods allow you to manage property change event handlers dynamically. If you only need to attach an event handler without removing it afterwards, you can use the onPropertyChanged
event instead.
An array of one or multiple property names.
handler, type: any ,A function to call when one of the listed properties change. Accepts a new property value as an argument.
key, type: string ,(Optional) A key that identifies the current registration. If a function for one of the properties is already registered with the same key, the function will be overwritten. You can also use the key to subsequently unregister handlers.
Removes a page from the survey.
Pass a PageModel
object to this method. You can get this object in different ways. For example, you can call the getPageByName()
method to obtain a PageModel
object with a specific name or use the currentPage
property to access and delete the current page, as shown in the code below.
// Delete the current page
survey.removePage(survey.currentPage);
A page to remove.
Specifies one or multiple characters that designate required questions.
Default value: *
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Calculates a given expression and returns true
or false
.
An expression to calculate.
Calculates a given expression and returns a result value.
An expression to calculate.
callback, type: (res: any) => void ,A callback function that you can use to access the calculation result if the expression uses asynchronous functions.
postId, type: string
clientId, type: string
isPartial, type: boolean
Sets a cookie with a specified cookieName
in the browser. If the cookieName
property value is defined, this method is automatically called on survey completion.
Assigns a new value to a specified property.
A property name.
val, type: any ,A new value for the property.
Sets a question value (answer).
This method executes all triggers and reevaluates conditions (
visibleIf
,requiredId
, and others). It also switches the survey to the next page if theautoAdvanceEnabled
property is enabled and all questions on the current page have correct answers.
A question name.
newQuestionValue, type: any
locNotification, type: any ,For internal use.
allowNotifyValueChanged, type: boolean ,For internal use.
questionName, type: string
Specifies whether to show the complete page.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies whether to show all survey elements, regardless of their visibility.
Default value: false
Specifies whether page titles contain page numbers.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies whether to display page titles.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies whether to display the Previous button. Set this property to false
if respondents should not move backward along the survey.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies whether to show a preview of given answers before they are submitted.
Default value: false
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies whether to display survey element numbers and how to calculate them.
Possible values:
true
or "on"
- Numbers survey elements in order, regardless of their nesting level."recursive"
- Applies recursive numbering to elements nested in panels (for example, 1 -> 1.1 -> 1.1.1, etc.)."onpage"
- Starts numbering on each page from scratch.false
or "off"
- Hides question numbers.If you want to hide the number of an individual question, disable its showNumber
property.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies the timer's visibility. Applies only to quiz surveys.
Default value: false
If you set this property to true
, the timer starts automatically when the survey begins. To specify time limits, use the timeLimit
and timeLimitPerPage
properties.
The timer displays information about time spent on an individual page and the entire survey. If you want to display only the page timer or the survey timer, set the timerInfoMode
property to "page"
or "survey"
.
You can enable the timer without displaying it. In this case, you need to specify the required time limits and use the startTimer()
and stopTimer()
methods to control the timer.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies whether to display the survey title.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Gets or sets the visibility of the table of contents.
Default value: false
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Obsolete. Use the startPage
property instead.
Returns the start page. Applies only if the firstPageIsStartPage
property is set to true
.
Refer to the following help topic for more information: Start Page.
Gets or sets a caption for the Start button.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Returns the current survey state.
Possible values:
"loading"
- The survey is being loaded from a JSON schema."empty"
- The survey has no elements to display."starting"
- The survey displays a start page."running"
- A respondent is taking the survey."preview"
- A respondent is previewing answers before submitting them."completed"
- A respondent has completed the survey and submitted the results.This property is stored in the survey JSON definition and can be edited in the Survey Creator.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies when to update the question value in questions with a text input field.
Possible values:
"onBlur"
(default) - Updates the value after the input field loses focus."onTyping"
- Updates the value on every key press.Do not use the
"onTyping"
mode if your survey contains many expressions. Expressions are re-evaluated each time a question value is changed. In"onTyping"
mode, the question value changes frequently. This may cause performance degradation.
You can override this setting for individual questions: textUpdateMode
.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
A time period that a respondent has to complete the survey; measured in seconds. Applies only to quiz surveys.
Default value: 0 (time is unlimited)
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
A time period that a respondent has to complete each survey page; measured in seconds. Applies only to quiz surveys.
Default value: 0 (time is unlimited)
You can also use PageModel
's timeLimit
property to specify a time period for an individual survey page.
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies whether the timer panel displays timers for the current page, the entire survey, or both. Applies only if the timer panel is visible.
Possible values:
"survey"
- Displays only the survey timer."page"
- Displays only the page timer."combined"
(default) - Displays both the survey and page timers.This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies the timer's position relative to the survey. Applies only if the showTimer
property is set to true
.
Possible values:
"top"
(default) - Displays the timer at the top of the survey."bottom"
- Displays the timer at the bottom of the survey.This property is stored in the survey JSON definition and can be edited in the Survey Creator.
A time period that a respondent has spent on the survey so far; measured in seconds. Applies only to quiz surveys.
Assign a number to this property if you need to start the quiz timer from a specific time (for instance, if you want to continue an interrupted quiz).
You can also find out how many seconds a respondent has spent on an individual survey page. To do this, use the timeSpent
property of a PageModel
object.
A title for the survey element. If title
is undefined, the name
property value is displayed instead.
Empty pages and panels do not display their titles or names.
Gets or sets the position of the table of contents. Applies only when the table of contents is visible.
Possible values:
"left"
(default)"right"
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Returns a JSON schema that corresponds to the current survey element.
An object with configuration options.
options.storeDefaults, type: boolean ,Pass true
if the JSON schema should include properties with default values.
A JSON schema of the survey element.
Completes the survey if it currently displays the last page and the page contains no validation errors. If both these conditions are met, this method returns true
; otherwise, false
.
If you want to complete the survey regardless of the current page and validation errors, use the doComplete()
event.
Unregisters value change event handlers for the specified properties.
An array of one or multiple property names.
key, type: string ,(Optional) A key of the registration that you want to cancel.
Uploads files to a server.
The following code shows how to call this method:
const question = survey.getQuestionByName("myFileQuestion");
survey.uploadFiles(
question,
question.name,
question.value,
(data, errors) => {
// ...
}
);
The File Upload question's name
or Signature Pad question's name
.
An array of JavaScript File objects that represent files to upload.
callback, type: (data: any, errors?: any) => any ,A callback function that allows you to access successfully uploaded files as the first argument. If any files fail to upload, the second argument contains an array of error messages.
Validates all questions and returns false
if the validation fails.
If you use validation expressions and at least one of them calls an async function, the validate
method returns undefined
. In this case, you should pass a callback function as the onAsyncValidation
parameter. The function's hasErrors
Boolean parameter will contain the validation result.
(Optional) Pass false
if you do not want to show validation errors in the UI.
(Optional) Pass true
if you want to focus the first question with a validation error. The survey will be switched to the page that contains this question if required.
(Optional) Pass a callback function. It accepts a Boolean hasErrors
parameter that equals true
if the validation fails or false
otherwise.
changeCurrentPage, type: boolean
Validates all questions on the current page and returns false
if the validation fails.
If you use validation expressions and at least one of them calls an async function, the validateCurrentPage
method returns undefined
. In this case, you should pass a callback function as the onAsyncValidation
parameter. The function's hasErrors
Boolean parameter will contain the validation result.
(Optional) Pass a callback function. It accepts a Boolean hasErrors
parameter that equals true
if the validation fails or false
otherwise.
Validates all questions on a specified page and returns false
if the validation fails.
If you use validation expressions and at least one of them calls an async function, the validatePage
method returns undefined
. In this case, you should pass a callback function as the onAsyncValidation
parameter. The function's hasErrors
Boolean parameter will contain the validation result.
Pass the PageModel
that you want to validate. You can pass undefined
to validate the activePage
.
(Optional) Pass a callback function. It accepts a Boolean hasErrors
parameter that equals true
if the validation fails or false
otherwise.
Specifies whether respondents can end a survey with validation errors.
Default value: false
Specifies whether respondents can switch the current page even if it contains validation errors.
Default value: false
Returns the number of visible survey pages.
To get a total number of survey pages, use the pageCount
property.
Returns an array of visible pages without the start page.
To get an array of all pages, use the pages
property. If all pages are visible, the pages
and visiblePages
arrays are identical.
A survey width in CSS values.
Default value: undefined
(the survey inherits the width from its container)
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
Specifies how to calculate the survey width.
Possible values:
"static"
- A survey has a fixed width."responsive"
- A survey occupies all available horizontal space and stretches or shrinks horizontally to fit in the screen size."auto"
(default) - Survey width depends on a question type and corresponds to the "static"
or "responsive"
mode.This property is stored in the survey JSON definition and can be edited in the Survey Creator.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4