Skip to content

Valid mobile number #1569

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

Closed

Conversation

salma-93
Copy link
Contributor

It is used to validate the length of the phone number. If it exceeds the maximum length, it displays an error message and clears the field.

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') return;

if (newValue.length>12) {

Choose a reason for hiding this comment

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

What if somebody uses spaces or dashes in the phone number? +1 (800) 123-4567 is 17 characters and is a valid format for a phone number in the US. Have you considered using a regex to test the phone number? Additionally there is a dedicated field type for phone numbers, so can you provide some context around when you would use this script instead of the field?

@wiz0floyd
Copy link

I've requested changes in the script. I'm concerned that this is too simple to include in the code snippets repo as length is not a very robust method for validation of a phone number.

@wiz0floyd wiz0floyd closed this Oct 30, 2024
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.

2 participants