Good day!
How to set likert scale control required? it doesn't work such as field fd.field('').reuired=true
i need all questions to be answered by the user
Dear @ixxxl,
Try to add a form validator which will check if there are any null or undefined values in a Likert Scale:
fd.rendered(function(){
fd.validators.push({
name: 'LikertScale validator',
error: 'Please, fill in Likert Scale',
validate: function() {
if (fd.control('LikertScale1').value.includes(null) || fd.control('LikertScale1').value.includes(undefined))
return false;
return true;
}
});
});
1 Like
Dear @ixxxl ,
For IE, try a more classic approach with indexOf instead of includes:
fd.rendered(function(){
fd.validators.push({
name: 'LikertScale validator',
error: 'Please, fill in Likert Scale',
validate: function() {
if (fd.control('LikertScale1').value.indexOf(null) > -1 || fd.control('LikertScale1').value.indexOf(undefined) > -1)
return false;
return true;
}
});
});
@Nikita_Kurguzov
Works perfect in explorer, but now doesn't work in chrome. Is it a way to work in both explorer and chrome ?
Dear @ixxxl,
Okay, had to think out of the box (asked devs for help), please, try the following:
fd.rendered(function(){
fd.validators.push({
name: 'LikertScale validator',
error: 'Please, fill in Likert Scale',
validate: function() {
var answersNumber = fd.control('LikertScale1').value.filter(function(e) { return e }).length;
var questionsNumber = 4;
if (answersNumber == questionsNumber)
return true;
return false;
}
});
});
1 Like