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

tel no. validation #10124

wants to merge 9 commits into from

Conversation

SharanRP
Copy link

@SharanRP SharanRP commented Feb 22, 2024

Resolves issue #9559 - Implemented a regular expression to restrict the pasting of alphabetical characters into the input field.

@pnorman
Copy link
Contributor

pnorman commented Feb 22, 2024

There seem to be changes unrelated to telephone numbers here. Could you also title your PR and add a comment so that it's obvious what it's for?

@SharanRP SharanRP changed the title Develop3 tel no. validation Feb 22, 2024
@SharanRP
Copy link
Author

I have updated the files and body of message

@SharanRP
Copy link
Author

SharanRP commented Mar 8, 2024

Is this correct now ? @pnorman

modules/ui/fields/input.js Outdated Show resolved Hide resolved
@SharanRP
Copy link
Author

SharanRP commented Mar 9, 2024

code updated to only neglect tel: or tel:// @1ec5

Comment on lines +416 to +417
val = val.replace(/^tel:\/\//, ''); // Remove 'tel://' prefix if present
val = val.replace(/^tel:/, ''); // Remove 'tel:' prefix if present
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 (!val && getVals(_tags).size > 1) return;

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably perform the tel:-stripping after cleaning the tag value. cleanTagValue() removes stuff like leading and trailing whitespace, something that can easily occur if someone is copy-pasting from another website.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants