Custom Fields
Re-Envisioned
Support General Creating Custom Field – Telephone

  • Creator
    Topic
  • #12252
    Resolved @mindspark
    Participant

    Hi Anh – I’ve read the KB on this, but what I don’t see in the instructions is:

    1. can you convert a standard text field to a TEL field by using an Attribute?
    2. what would be the complete string to add into the functions.php file to create the new field type as an option in the meta-builder?

    thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Author
    Replies
  • #12285
    Anh Tran
    Keymaster

    Hi Neil,

    1. Yes, it’s possible. Please just change the type from text to tel and you already have telephone field. It’s actually a HTML5 input type and I already covered it here.

    2. The Meta Box Builder could not be extended that way. If you create a new field type, it’s available for coding only. It won’t show in the Builder.

    #12296
    @mindspark
    Participant

    Thx Anh –

    I don’t know WHERE to change the field type from Text to TEL….? there isn’t an option in the builder itself that I can find

    #12314
    Anh Tran
    Keymaster

    Ah, you’re using the Meta Box Builder :). I was saying about using code.

    In Meta Box Builder, to change the type, please go to Advanced tab, try add a custom attribute type with value tel.

    #12328
    @mindspark
    Participant

    so sorry about this….

    which field type do I select? there is no option for HTML5 or anything related to text?

    see here: https://snag.gy/CX69fH.jpg

    #12330
    @mindspark
    Participant

    please disregard my last note.

    Using a TEXT field, I went to Advanced tab and in Attributes I added TYPE and TEL.

    after updating, the field still allows me to enter text and numbers are not formatted as a telephone number.

    see here:

    setting attribute – https://snag.gy/61TK29.jpg
    number not formatted as phone number – https://snag.gy/gG3d2n.jpg
    field accepts text vs numbers – https://snag.gy/mcPKxk.jpg

    #12357
    Anh Tran
    Keymaster

    Hi Neil,

    The tel input still allows to enter text. In order to force a format, please add another custom attribute with name pattern and value like [0-9]{3}-[0-9]{3}-[0-9]{4} (123-456-7890). Then the plugin will use that pattern as a validator for data entered.

    Please note that the value is a regular expression, where [0-9] means only numbers, {3} means only 3 times. For more info, please read this guide.

    #12361
    @mindspark
    Participant

    Hi Anh – I found the patterns detail on my own yesterday… I was assuming that the pattern allows for real-time field validation. unfortunately the pattern method only validates on submission. 🙁

    as always thanks for your efforts here!

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.