Hello,
I have a form made with CF v5 and I tried to make a select-multiple field required.
It didn't work... The form was submitted even if no option was selected.
The validation worked for each other field.
I solved my problem by hacking the gvalidation.js file ([Joomla-root]/libraries/cegcore/assets/gplugins/gvalidation/gvalidation.js)
I added the code below after line 122 :
I guess it is not a good practise...
Was it the best way to solve my problem ?
Is the added code good enough ?
I have a form made with CF v5 and I tried to make a select-multiple field required.
It didn't work... The form was submitted even if no option was selected.
The validation worked for each other field.
I solved my problem by hacking the gvalidation.js file ([Joomla-root]/libraries/cegcore/assets/gplugins/gvalidation/gvalidation.js)
I added the code below after line 122 :
else if($type == "select-multiple")
{
var nullval = ($this.val()?$this.val()[0]:"");
if($rule_parts[0] == 'required'){
return nullval.trim().match(GValidtaion.rules[$rule_parts[0]]);
}else{
return (!nullval.trim() || nullval.trim().match(GValidtaion.rules[$rule_parts[0]]));
}
}
I guess it is not a good practise...
Was it the best way to solve my problem ?
Is the added code good enough ?