Creating Custom Field - Telephone
- This topic has 9 replies, 4 voices, and was last updated 2 years, 9 months ago by
[email protected].
-
AuthorPosts
-
November 26, 2018 at 8:19 PM #12252
@mindspark
ParticipantHi Anh - I've read the KB on this, but what I don't see in the instructions is:
- can you convert a standard text field to a TEL field by using an Attribute?
- 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
November 27, 2018 at 1:56 PM #12285Anh Tran
KeymasterHi Neil,
-
Yes, it's possible. Please just change the
type
fromtext
totel
and you already have telephone field. It's actually a HTML5 input type and I already covered it here. -
The MB 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.
November 27, 2018 at 6:49 PM #12296@mindspark
ParticipantThx 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
November 28, 2018 at 11:33 AM #12314Anh Tran
KeymasterAh, you're using the MB Builder :). I was saying about using code.
In MB Builder, to change the type, please go to Advanced tab, try add a custom attribute
type
with valuetel
.November 28, 2018 at 7:18 PM #12328@mindspark
Participantso 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
November 28, 2018 at 7:26 PM #12330@mindspark
Participantplease 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.jpgNovember 29, 2018 at 4:38 PM #12357Anh Tran
KeymasterHi Neil,
The
tel
input still allows to enter text. In order to force a format, please add another custom attribute with namepattern
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.November 29, 2018 at 6:53 PM #12361@mindspark
ParticipantHi 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!
December 19, 2019 at 8:47 PM #17589tech500
ParticipantHi,
I'm using the MB Builder for a phone number field, and the number doesn't get formated to a phone number format like the custom attribute mentioned.
Tried both text & number field types, and also added the "tel" type attribute.How can I get a phone number format properly?
Thanks
DanJune 30, 2022 at 11:42 PM #36746[email protected]
ParticipantI have a text box that I need to be clickable to call for a phone number. I've tried everything. Should be pretty simple. I have a setting page with client numbers and have selected the number in elementor. I prepended the text with tel: however, it is not calling instead it's going to a broken link. URL doesn't work either.
-
AuthorPosts
- You must be logged in to reply to this topic.