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

US Phone validation always displays "must consist of only numbers" even if the error is not enough digits were entered, etc #104

Open
1 task done
MaxwellGarceau opened this issue Jan 2, 2025 · 2 comments · May be fixed by #112
Assignees
Labels
type:bug Something isn't working.
Milestone

Comments

@MaxwellGarceau
Copy link
Collaborator

Describe the bug

Entering too few digits, even if all digits are numbers, for a valid phone number will display in a confusing error message of "Phone Number must consist of only numbers".

Explanation

The validation is looking for 12 characters. If it can't find 12 it sets the entire input to an empty string. This causes the regex validation to fail and the code execution continues to an error message intended for input that contained something other than numbers.

Solution

We just have to update the validation check to fail with a valid error message.

Steps to Reproduce

  1. Set the phone format in the test Mailchimp account (/lists/settings/merge-tags) to US style
  2. Select the "Update List" button to refresh the Mailchimp data with WP
  3. Include the Phone Number merge field in the Mailchimp settings
  4. Submit a form submission with one digit less in any input

Screenshots, screen recording, code snippet

phone-number-missing-digits-displays-wrong-validation-message.mov

Environment information

No response

WordPress information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@MaxwellGarceau
Copy link
Collaborator Author

Related to #101

@MaxwellGarceau
Copy link
Collaborator Author

MaxwellGarceau commented Jan 3, 2025

Whitespace testing

All whitespace should be stripped and should return an error notifying the user that the phone number does not have enough digits

1 3 - 12 - 234 should fail validation with an error messaging stating that there are not enough digits


Previously, a user could also enter 12 3 for the last group of digits and pass validation.

@MaxwellGarceau MaxwellGarceau self-assigned this Jan 4, 2025
@jeffpaul jeffpaul modified the milestones: 1.8.0, 1.7.0 Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working.
Projects
None yet
2 participants