AskerJs accepts a questions
object as a parameter once initialized. This would define the questions the form will ask the user.
Here’s what that object should look like.
let questions = {
'question-1':{
type: 'text', // The question type
text:"What's ya name?",
required: false,
next: 'question-2' // The next question. If not provided, the form will submit.
},
'question-2':{
type: 'text',
text: "What's ya email?",
required: true, // Whether the user can skip. Also, define a min value.
min: 10; // The minimum characters required.
}
}
Property | Definition | Options | Type |
---|---|---|---|
type (required) |
The question type. AskerJs currently supports six types. | text |
singleChoice |
text (required) |
The question’s heading text. AskerJs will render this to the DOM. | String |
|
required |
Whether the user can skip by clicking the next button. You should also define a min value. |
true |
false |
choices |
|||
*required if type = singleChoice |
multiChoice * |
The choices the user can choose from is the question type is single choice or multi-choice. | |
next |
The next question’s name. The name should match a key inside the question object. |
If not provided, AskerJs will assume the form is complete. | | String
|
| description
| Question description. You can give the user more info using this feature. | | String
|
| min
| The minimum number of characters required by the question. | | Number
|
| max
| The maximum number of characters allowed by the question. | | Number
|