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

Closed

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

Activity

  1. added
    type:bug
    and removed on Jan 2, 2025
  2. added this to the 1.8.0 milestone on Jan 3, 2025
  3. MaxwellGarceau commented on Jan 3, 2025

    @MaxwellGarceau
    ContributorAuthor

    Related to #101

  4. MaxwellGarceau commented on Jan 3, 2025

    @MaxwellGarceau
    ContributorAuthor

    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.

  5. modified the milestones: 1.8.0, 1.7.0 on Jan 9, 2025
  6. modified the milestones: 1.7.0, Future Release on Mar 31, 2025
  7. self-assigned this
    on May 19, 2025
  8. modified the milestones: Future Release, 2.0.0 on Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type:bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions