Add the following field to any module manifest
<field
name="test"
type="text"
description="testing field validation"
filter="string"
label="Test"
pattern="[A-Za-z\s0-9]+" />
Click on the test field and then select another without filling anything in. This will happen on any form which uses JFormValidator / JHtml::_('behavior.formvalidator');
The field to not be marked as invalid
Gets highlighted red and marked as invalid.
Joomla 3.8.5
Optional fields should only validate a pattern when a value is present. validate.js already checks for value.length but defaults to false if length is 0: https://github.com/joomla/joomla-cms/blob/staging/media/system/js/validate-uncompressed.js#L89-L96. Removing the else statement solves this but i'm not sure if this had been added intentionally.
This same issue is also present with J4.
Labels |
Added:
?
|
Category | ⇒ | Fields |
J4 has the code you’re looking for, someone needs to backport it here
Status | New | ⇒ | Discussion |
Looks like J4 will have the same issue: https://github.com/joomla/joomla-cms/blob/4.0-dev/media/system/js/fields/validate.js#L165-L172. It defaults to false in the else statement, can this default to true instead?
Closed_By | franz-wohlkoenig | ⇒ | joomla-cms-bot |
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-02-24 10:37:42 |
Closed_By | ⇒ | franz-wohlkoenig |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/19751
make sense
something like this snippet for https://github.com/joomla/joomla-cms/blob/staging/media/system/js/validate-uncompressed.js#L89-L96