Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Not a bug
-
2.3.3
-
None
-
None
-
MOODLE_23_STABLE
Description
I am a very new Moodle fan so apologies if this is not a bug but a misuse (I haven´t read all docs yet ).
The issue is that when I add a rule to a field in a subclass of moodleform_mod I use the syntax:
$mform->addRule('myfield', get_string('myErrorMessageId','myMod'), 'regex', "myRegexpression", 'client');
but the generated javascript code is, supposed myRegExpression is "[0-9]
{0,5}":var regex = [0-9]{0,5}
;
but, if I am not wrong, it should be:
var regex = '[0-9]{0,5}';
If you take a look at file moodleroot/lib/pear/HTML/QuickForm/Rule/Regex.php , you'll find the following sentence in line 84 (moodle 2.3):
return array(" var regex = " . $regex . ";\n", "{jsVar} != '' && !regex.test({jsVar})");
I guess if it should rather be:
return array(" var regex = '" . $regex . "' ;\n", "{jsVar} != '' && !regex.test({jsVar})");
Notice the opening and closing quote surrounding the value of $regex.
Attachments
Issue Links
- has been marked as being related by
-
MDL-42529 Documentation and rules for form validations
-
- Open
-