Issue summary
After enabling webform_intl_tel_national_mode, the improved national-mode UX works, but client-side validation appears to stop working.
Example:
- enable Webform telephone international mode
- enable webform_intl_tel_national_mode
- enter obvious invalid input such as letters
- submit the form
Actual result:
- no validation error is shown
- invalid values can pass client-side validation
Expected result:
- invalid values should still fail intlTelInput('isValidNumber') validation
Root cause
In the module’s JS override:
[webform_intl_tel_national_mode/js/webform.element.telephone.js]
the validation guard uses:
if ($telephone.text().trim()) {
But $telephone is an , so .text() is empty. For input elements this should be .val().
Because of that, the validation block never runs.
Proposed fix
Change:
if ($telephone.text().trim()) {
to:
if ($telephone.val().trim()) {
Comments
Comment #2
danrodComment #3
danrodComment #5
danrodThanks, I created a MR with your patch and it works as expected, I also added a regular expression to accept phone numbers such as 012 345 6789, 1012 345 6789, and +1012 345 6789 but also not to accept invalid input such as letters. I'll merge this shortly.
Comment #6
danrodComment #7
danrodComment #9
danrod