18 require_once dirname(__FILE__).
'/../../form_question_rule/form_question_rule.inc';
43 parent::__construct($assetid);
58 1 => translate(
'core_form_rule_integer_true'),
59 0 => translate(
'core_form_rule_integer_false'),
78 static $printed_fn =
false;
80 $operator = array_get_index($rule_data,
'operator', 1);
83 $regex_code =
'/^[-+]?\d+$/';
91 function sq_form_validate_integer(answer)
93 answer.replace(/,/,
"");
94 return answer.match(<?php echo $regex_code ?>);
102 if (<?php echo ($operator == 1) ?
'!' :
''; ?>sq_form_validate_integer(form.elements[
"q<?php echo $q_asset->id; ?>"].value)) {
103 submission_errors[submission_errors.length] =
"<?php
104 if (empty($rule_data['custom_text'])) {
105 echo addslashes($this->defaultError($q_asset, $rule_data));
107 echo addslashes($rule_data['custom_text']);
113 $contents = ob_get_contents();
135 $operator = array_get_index($rule_data,
'operator', 1);
137 $valid = (is_numeric($answer) && ($answer == (int)$answer)) ? 1 : 0;
138 return ($valid == $operator);
154 $operator = array_get_index($rule_data,
'operator', 1);
155 $error_str = translate(
'core_form_rule_integer_desc_'.($operator ?
'true' :
'false'), $q_asset->attr(
'name'));