Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tel no. validation #10124

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/ui/fields/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ export function uiFieldText(field, context) {
var val = utilGetSetValue(input);

if (field.type === 'tel') {
val = val.replace(/[^0-9+]/g, '');
val = val.replace(/^tel:\/\//, ''); // Remove 'tel://' prefix if present
val = val.replace(/^tel:/, ''); // Remove 'tel:' prefix if present
Comment on lines +416 to +417
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these are regular expressions, you could combine these two steps by surrounding the slashes in (\/\/)?. (Technically, RFC 3966 doesn’t allow slashes after the colon, but as #9559 (comment) demonstrates, there’s probably enough confusion about that to go ahead and strip out those slashes too.)

}

if (!onInput) val = context.cleanTagValue(val);
Expand Down