Validate the questions by using the questioncheck() function
Validate the questions of questionnaire by using the questioncheck() function
- The Javascript function questioncheck() is where all the question validation stuff will be implemented. Therefore, to implement your own question validation stuff which not supported by the Catglobe system, you need to overwrite this function.
- The questioncheck() function will be called/invoked by the quest.next() function when the Next button is clicked.
- It is required that the questioncheck() function must return the boolean values (true/false). If true, the answer value of question is valid, else the answers value of question is invalid.
- To display error messages when the answer of question is invalid. You could use the Javascript alert() function or add your error message texts to the container which has the id: #errorMessages
- In most cases, you should copy the questioncheck() before overwriting it by your own questioncheck function. To copy the questioncheck and overwrite it, please see below snippnet:
var old_questioncheck = questioncheck(); // This line copy the questioncheck()
questioncheck = function() { // This line overwrite the questioncheck() by your own questioncheck
if(!old_questioncheck()) // In most cases, we will reuse the old questioncheck to implement the validation rules that supported by Catglobe system
return false;
// If the old questioncheck detects that the answer of question is valid with its own rules, then we will continue with our validation rules.
// Implement your own validation rules below
// Your own validation rule coldes here.....numeric validation codes...
// Remember that it is required the this function must return the boolean values (true/false)
};