Now that we've learned how to create specific form elements, let's explore what else formslib can do for us.
You can add rules to perform validation of the data entered into form elements. These rules can be applied either during the entry process, or after submission.
Rules provide an easy and reusable way to apply common data checks without having to rewrite code every time.
To add a rule to a form element, use the following code syntax:
$mform->addRule($elementname, $errorstring, $ruletype, $ruledata, $validation);
The first parameter is the name of the form element to apply the rule to. The second parameter defines an error string to display if the rule fails.
The third parameter is the name of the rule. This name must be a valid rule already registered with the form.
The fourth parameter contains any optional data that needs to be passed to the rule for this element; for example, the maximum length of the data for a maxlength
rule.
The fifth parameter...