Skip to content

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

@MaxwellGarceau

Description

@MaxwellGarceau

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

Metadata

Metadata

Assignees

Labels

type:bugSomething isn't working.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions