User tests: Successful: Unsuccessful:
According to this documentation: https://docs.joomla.org/Tel_form_field_type is "tel" form field an alias for "text", but it does not contain "pattern" attribute. This means, XML form field types "tel" will not include pattern attribute when rendering.
BEFORE PR
AFTER PR
Example:
<field name="phone_1" type="tel" label="COM_XXX_PHONE_1_LABEL" description="COM_XXX_PHONE_1_DESC" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" validate="tel" class=" validate-tel" />
will produce
BEFORE PR:
<input type="tel" inputmode="tel" name="jform[phone_1]" class="form-control validate-tel" id="jform_phone_1" value="" aria-describedby="jform_phone_1-desc">
AFTER PR:
<input type="tel" inputmode="tel" name="jform[phone_1]" class="form-control validate-tel" id="jform_phone_1" value="" aria-describedby="jform_phone_1-desc" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}">
Adding option to add "pattern" attribute into the "tel" form field like it is included in "text" form field
Edit the file, create form field with tel type and pattern. Such field will include pattern attribute when rendering.
Pattern attribute is not rendered in "tel" form fields
Pattern attribute is rendered in "tel" form fields
Status | New | ⇒ | Pending |
Category | ⇒ | Layout |
Google has a phone number pattern library. Not sure if it make sense for US but at least it's the correct one.
In the end phone numbers are saved by domain providers with +43,15346454.
I would suggest not to validate any fix pattern luk suggested.
I talk about this lib https://github.com/google/libphonenumber
Hi, I personally agree with you, but this PR is not about what the recommendation is - to use or not to use the "tel" form field, but to add the missing option.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/tel
HTML Input type tel form field includes the attribute option "pattern" which is not rendered by Joomla Form library even it is set in XML.
Even if we can think anything about the tel type, the missing option to add the pattern attribute is essential for this type.
I have tested this item
Works as expected.
I have tested this item
patern
is valid attribute for the input.
Status | Pending | ⇒ | Ready to Commit |
r2c
Labels |
Added:
?
?
|
Just to be sure about this change. When an extension had a form with a pattern attribute on a tel field, then it didn't comply before this change but does now after it? Even when it is a bugfix, I would rebase this to 5.0 as it adds a new behavior.
Yes, the attribute was ignored before.
The PR is fixing that, I do not see a reason to wait for 5, it a simple bug fix
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-10-15 09:24:21 |
Closed_By | ⇒ | HLeithner |
The documentation needs to be updated
The tel format is useless and really should have been removed but b/c prevented it.
There is no global standard for a telephone number pattern. Far too often on sites that does use this input type and a pattern I end up putting my number in completely the wrong places just to satisfy a pattern that does not apply to my number.