73 if (form[
"{$this->field}"].
style.display !=
"none" && form[
"{$this->field}"].value ==
"{$this->empty}")
75 alert(
"{$this->title} is a required field. Please supply a value.");
96 $value = $this->answer->value;
99 if ($value != $this->empty)
105 return "{$this->title} is a required field.";
128 $this->text = (
$min < 2) ?
"checkbox" :
"checkboxes";
136 var countChecked = 0;
137 var
max = form[
"count_{$this->field}"].value;
140 for(i=1; i <=
max; i++)
142 fieldName = form[
"{$this->field}["+i+
"]"];
143 if(fieldName.checked ==
true)
147 if ({$this->min} > 0 && countChecked < {$this->min})
149 alert(
"You must check at least {$this->min} {$this->text} for {$this->title}.");
165 if (is_array($values))
166 $valueAnswer = implode(
",", array_values($values));
170 $valueAnswer = $this->answer->value;
173 if (strlen($valueAnswer) > 1)
174 $count = count(explode(
",", $valueAnswer));
180 if ($count < $this->min)
182 return "You must check at least {$this->min} {$this->text} for {$this->title}.";
213 var countChecked = 0;
214 var
max = form[
"count_{$this->field}"].value;
217 for(i=1; i <=
max; i++)
219 fieldName = form[
"{$this->field}_"+i];
220 if(fieldName.checked)
225 if (countChecked < 1)
227 alert(
"You must select an option for {$this->title}.");
245 $value = $this->answer->value;
250 return "You must select an option for {$this->title}.";
277 $this->conditionalFields[] =
"recipients";
279 if(
$form->data->hasField(
"additional_recipients"))
281 $this->conditionalFields[] =
"additional_recipients";
284 if(
$form->data->hasField(
"cc_recipients"))
286 $this->conditionalFields[] =
"cc_recipients";
292 if ($this->readOnly)
return "";
294 if(count($this->conditionalFields) > 0)
296 $conditions = array();
297 foreach($this->conditionalFields as
$field)
299 $conditions[] =
"form[\"{$field}\"].value != \"{$this->empty}\"";
301 $conditions =
"(" . implode(
" || ", $conditions) .
") && ";
306 if ({$conditions}form[
"{$this->field}"].value ==
"{$this->empty}")
308 alert(
"{$this->title} is a required field. Please supply a value.");
320 if ($this->readOnly)
return "";
323 if(count($this->conditionalFields) > 0)
325 foreach($this->conditionalFields as
$field)
327 if(isset(
$_POST[$this->
field]) && $_POST[$this->field] !== $this->empty)
334 if ((!isset(
$_POST[$this->
field]) || $_POST[$this->field] === $this->empty)
335 && (!count($this->conditionalFields) || !$empty))
337 return "{$this->title} is a required field.";
static usingFeature()
Uses the specified framework feature(s).
RequiredCheckListQuestion Validator.
RequiredCheckListQuestionValidator($field, $title, $min=0, $answer="")
RequiredQuestion Validator.
RequiredQuestionValidator($field, $title, $empty="", $answer="")
If a survey allows anonymous responses, then email message is only required if the user enters a reci...
__construct($form, $field, $title="", $message="")