Telephone Field

5 years 4 months ago #308772 by adgilcan
Telephone Field was created by adgilcan
It must be possible but I don't see it:

How do you constrain a form field to conform to telephone number format? These have been known to be a little USA centric sometimes but is it possible to force a field to format a field for telephone numbers, rather like Apple Contacts does?

Many thanks

D

Please Log in to join the conversation.

5 years 4 months ago #308798 by krileon
Replied by krileon on topic Telephone Field
Use a text field with custom REGEXP validation to force it to be in a specific format. Customize the validation error to let them know it needs to be in whatever format you're wanting. All of this is under on the Parameters > Validation tab of the text field. We've no input masking feature that auto formats for them, but that's doable with anything that'll let you output custom JS (you'll need to provide the necessary JS for the input masking).


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: nant

Please Log in to join the conversation.

5 years 4 months ago #308804 by adgilcan
Replied by adgilcan on topic Telephone Field
Thanks

That quickly gets waaaay too complex for me. It seems one should use a specialised library given gthe multiple options across countries foir telephone number format. Google's libphonenumber seems to be suggested as a good one but I have no idea how to incorporate that here.

I'll leave that for another day.


Thanks again


D

Please Log in to join the conversation.

5 years 4 months ago - 5 years 4 months ago #308811 by krileon
Replied by krileon on topic Telephone Field
You don't need a massive library to match phone number. It can be done relatively easily using REGEXP. Have added a feature ticket to extend the built in pre-configured REGEXP dropdown with some more options.

forge.joomlapolis.com/issues/7362

If you're not familiar with REGEX the below site is a good tool to help learn as well as quickly test your REGEX.

regexr.com/

Additionally you should be able to use any of the available REGEX sites to find pre-made REGEX.

regexlib.com/

Quick search also finds the below stackoverflow page with a pretty solid example.

stackoverflow.com/a/16699507/2449290

We're also still exploring the possibility of adding support for input masks.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: nant

Please Log in to join the conversation.

5 years 4 months ago #308815 by adgilcan
Replied by adgilcan on topic Telephone Field
Thanks

Thats very useful stuff. I will spend some time getting to grips with it.

Many thanks


D
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

4 years 11 months ago #311939 by ernienet
Replied by ernienet on topic Telephone Field
Yes - input masks that your code would translate would be extremely valuable so that non-coders can customize text fields with specific formats. I tried to figure out how to input a "Custom PERL regular expression", but I couldn't figure it out after reading several search results - CB wouldn't accept what I entered.

If someone could simply enter "literals" plus "variables" and your code interpret it, I could enter (###) ###-#### and CB would know that the parentheses, spaces and dashes are literals and the # are variables. Use of [] to define ranges, etc. - the standard stuff I've seen elsewhere, with the flyover help giving a a brief explanation of how to create an input mask, it would be a very helpful enhancement.

Thank you,
Ernie

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.220 seconds

Facebook Twitter LinkedIn