18 require_once dirname(__FILE__).
'/../../form_question_rule/form_question_rule.inc';
19 require_once SQ_FUDGE_PATH.
'/general/www.inc';
45 parent::__construct($assetid);
62 1 => translate(
'core_form_rule_email_true'),
63 0 => translate(
'core_form_rule_email_false'),
82 $operator = array_get_index($rule_data,
'operator', 1);
83 $function_id = preg_replace(
'/[^a-zA-Z0-9]/',
'_', $q_asset->id);
85 $local =
'\da-zA-Z-_+';
86 $local_middle = $local.
'.\w';
87 $regex_code =
'/^(['.$local.
']['.$local_middle.
'\']*[
'.$local.']@[\da-zA-Z][\
'-.\w]*[\da-zA-Z]\.[a-zA-Z]{2,7})$/';
89 function sq_form_validate_email_<?php echo $function_id; ?>(answer)
92 if (!$q_asset->attr(
'is_required')) {
94 if (answer.length == 0) {
100 answer.replace(/,/,
"");
101 return answer.match(<?php echo $regex_code ?>);
105 if (<?php echo ($operator == 1) ?
'!' :
''; ?>sq_form_validate_email_<?php echo $function_id; ?>(form.elements[
"q<?php echo $q_asset->id; ?>"].value)) {
106 submission_errors[submission_errors.length] =
"<?php
107 if (empty($rule_data['custom_text'])) {
108 echo addslashes($this->defaultError($q_asset, $rule_data));
110 echo addslashes($rule_data['custom_text']);
116 $contents = ob_get_contents();
138 $operator = array_get_index($rule_data,
'operator', 1);
140 $valid = valid_email($answer);
141 return ($valid == $operator);
157 $error_str = translate(
'core_form_rule_email_desc_'.(array_get_index($rule_data,
'operator', 1) ?
'true' :
'false'), $q_asset->attr(
'name'));