• Resolved airdrummer

    (@airdrummer)


    i had the optional field pattern for a phone number set to nnn-nnn-nnnn (i also tried 000-000-0000; i couldn’t find anything on this in docs) but entering 123-456-7890 results in the unhelpful error msg

    “please match the requested format”

    not only does it reject a valid number, it doesn’t tell u what the pattern is:-\

    it would be nice to have this work, with the pattern revealed on error…

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Chad Butler

    (@cbutlerjr)

    “pattern” is an HTML5 input attribute, so it’s not anything specific to the plugin. A pattern must be a regular expression (regex) in a format recognized by HTML5.

    See: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern

    A regex for an input of 000-000-0000 can be specified as follows:

    [0-9]{3}[\-][0-9]{3}[\-][0-9]{4}

    “[0-9]” means you are only accepting a value consisting of any characters 0-9, {3} means three characters, [\-] is the dash (which has to be escaped with “\”). There are other valid ways to specify the same pattern, so if you search the Internet for possible regexes for this type of input, you will likely find varying results.

    The generic error message comes from the browser if no “title” attribute is specified (also an HTML5 input attribute). If you want the error message to be more helpful, use the “title” attribute to give the user guidance on input format.

    Thread Starter airdrummer

    (@airdrummer)

    that’s very helpful, thanx, chad:-) may i suggest adding it to the docs
    https://rocketgeek.com/plugins/wp-members/docs/plugin-settings/fields/
    or more helpfully on the add field tab, as you do on field label & metakey

    Plugin Author Chad Butler

    (@cbutlerjr)

    Now that the 3.4.0 update is finalized, I’ll be combing through all of the docs for a complete upgrade (I try to update as we go, but when a major release comes, like 3.3.x to 3.4.x, then I generally give the entire thing a re-do). The whole fields tab needs much better documentation all around, so this will be part of it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘field pattern can’t be satisfied:-(’ is closed to new replies.