Pebble template phone number format - template-engine

I wanted to format phone number which is passed as a string/number. I need to format that number to phone number like
Input to pebble template "5554781123". Output should be like "555.478.1123".
How do i format that number to phone number?

Generally speaking, whenever no function/filter is provided out of the box, in Pebble you can define your own function or filter (you can find more here on how to extend Pebble by creating and registering functions, filters and tests).
So you can wrap this solution into your own Pebble filter or function.

Related

phone number field in advanced custom field on wordpress

how to validate phone number field in advanced custom field on wordpress.Minimum number and maximum number and type only number.
/^(\d[\s-]?)?[([\s-]{0,2}?\d{3}[)]\s-]{0,2}?\d{3}[\s-]?\d{4}$/i
If you don't want to develop your own code, you can use the Advanced Custom Fields plugin (https://wordpress.org/plugins/validated-field-for-acf/) and then use RegEx to define the allowed phone number pattern for example:
/^(\d[\s-]?)?[\(\[\s-]{0,2}?\d{3}[\)\]\s-]{0,2}?\d{3}[\s-]?\d{4}$/i
This pattern will work for a range of phone numbers but you can adapt the RegEx to your specific requirements. There already is a post on phone number validation at:
A comprehensive regex for phone number validation
I hope this helps.

Format phone number in freemarker

I have a 10 digit number , which needs to be displayed as formatted phone number.
Eg: 1234567890 needs to be formatted in (123) 456-7890
I have tried formatting it using built-ins for numbers in freemarker, but somehow still not able to get it in expected format.
I don't think that's possible with Java SimpleNumberFormat patterns, which is what FreeMarker uses when you write things like '0.##'. But there are no limitations with custom number formats (see http://freemarker.org/docs/pgui_config_custom_formats.html), like, you could have something like ${n?string.#phone} that can do all kind of Java logic.
However, I would like to note that perhaps there's a problem there in the data model itself. In reality, phone numbers are not numbers, but stings (or even structures). They can have significant characters in them like + (or even #). Not to mention /, in case you have to dial extensions.

standardized international phone number field format as a string

I'd like to store phone numbers as unique user ids in my database/app which will initially roll out in the United States but could expand to other countries eventually.
My question is when storing phone numbers, what's a resilient way to store the number as a string so that I don't have any duplicate numbers from other countries overlap.
My initial thought is to do it this way
+1(212)555-5555
+{countryCode}({areaCode}){{subscriberCode}} *formatted with a hyphen for u.s numbers
Does that seem reasonable or are there any pitfalls to that? Should spaces be used? For instance I can't imagine other countries would use spaces or parenthesis in their subscriber codes... but maybe they do? It would also be nice if it followed the standard output format from ios and android phones' address books.
Here's what I'd say:
Use the plus. It indicates for certain that the country code follows and the number is not in a local format. You could also not store the plus and make an internal decision that all phone numbers will be stored with the country code, thus obviating the need for the plus.
Don't use any formatting in the storage of the number. Formatting is irrelevant when it comes to dialing and it makes searching and comparing more difficult.
Use a gem like phony_rails or phoney to format the number to local conventions when displaying.
So it looks like there is an international standard
http://en.wikipedia.org/wiki/E.164
And a node.js library that can format to that standard
https://github.com/aftership/node-phone

Visual Basic - Website Form Calculation

I am studying my first year in Programming and I have a slight problem in relation to Visual Basic coding. I know this sounds slightly vague, however I just wish to find out whether i need to create a variable, array or function.
I am creating a website app which processes a mobile phone order. I have designed a form which includes the quantity of mobile phones a particular customer requires, and the type of mobile phone the customer wishes to order.
I have included quantity values from 1-5 and 5 different types of mobile phones. I also have a button 'Process Order'. I just want to know how i can assign a particular type of mobile to the quantity.
In other words a calculation function where if I click process order, a price will be displayed showing exactly how much it costs for the phone + quantity needed. I have included a combo box with the list of phone types and the prices of each phone.
I want to be able to create a code which links a phone to a quantity for example Qty: 2 Type: superphone (costing £45). Once i process the order I should see a total price of £90. I am not expecting anyone to do it for me, just a simple explanation of what i need to look at in order to figure out the coding :)
It sounds like you are searching for the Dictionary class.
A dictionary matches some input (called key) to an output (called value). In principle, the same can be achieved through a function but a dictionary is more concise, can be changed at runtime, and may also be more efficient.
Conceptually, an array is just a specific type of dictionary that maps the input values 0 – n (its indices) to the indexed values.
Example:
Dim phonePrices As New Dictionary(Of String, Decimal)()
phonePrices.Add("Nookia", 12.30)
phonePrices.Add("Motolola", 12.12)
phonePrices.Add("THC", 42.00)
These prices can then be looked up by using the indexer:
Dim priceOfMyNookia = phonePrices("Nookia")

Is there a grid control or other "n" numbered-item control for Outlook Forms?

I'm developing an Outlook Form (2007) and I'm looking for a way to give the client the ability to enter an unspecified number of items - a grid, or some other way of doing this.
Is there a way to do this, or am I stuck with providing them with a fixed set of controls to enter items into?
It is not clear what the items are but from your suggestion of a grid I will presume they are values (numbers, strings, etc). If so you could almost certainly use something like comma separated values (CSV), or some other deliminator, for a standard text field.
In Outlook 2007 the To address field uses this functionality, in it the semi-colon is used to deliminate an 'unspecified number of items' - in this case email addresses.
This allows the user to enter data such as:
foo#bar.com; bat#baz.com; etc ...
Obviously CSV input would be:
something, something-else, etc ...
The other way to achieve this would be to dynamically generate the fields as required, that is programmatically build the form elements based on the user input, providing extra fields as required. For example, a simple system for multiple inputs might be work using the following logic.
Input entered -> check validity -> create new input
So that for each valid entry in a input, a new input is created below it, etc. thus allowing for an arbitrary number of input items.

Resources