My rails app have a field where users can enter their contact number and I'm using tel: like this to display:
<%= link_to sample.phone, "tel:#{sample.phone}" %>
So if the user entered a number in the phone field like this: 0176-40206387, the display will also be 0176-40206387
And if the user entered a number in the phone field like this: 017640206387, the display will also be 017640206387
As a newbie, I do not know which format a mobile phone can call, or will the phone automatically converts the number to a callable number? If not, what correct format is callable to tell the user how to enter their phone number?
You should consider use number_to_phone
Also, you can check this link to help you how to make phone calls in ruby
If you are going to be collecting phone numbers from users you need to make sure that you strip it of white space and prior to storage with something like this
sample.phone.gsub(/\D/, '')
That way you store the raw phone number.
Then in the view you can use the number_to_phone view helper like Lucas mentioned
number_to_phone( sample.phone, area_code: true)
If you want you could even just store the formatted phone number so you don't have to format it every time you want to view it.
Related
I’m developing an Messages extension. When it comes time to send a message, I want it to show up as something like: “Jeff sent a message.”
However, the MSConversation APIs only give us identifiers. When you use these identifiers in the MSMessage layout, it’s supposed to convert them to a name. When I attempt to do this, I see that it does indeed convert the identifier, but it converts it to the phone number of the participant rather than their name.
In other words, the following:
layout.caption = "$\(uuidOfTheParticipant) sent a message"
Shows up as “+15555551234 sent a message”. I’d like it to show a name instead of the phone number.
I searched the documentation to verify that this should be the behavior. I found out it was documented in the WWDC 2016 session 224 video. This was called “iMessage Apps and Stickers Part 2”. The video has been taken down since, so I had to rely on this transcript, where it states:
similarly, you can use these identifiers in the text passed to the Messages sumamaryText. When Messages displays the UI for the bubbles with this type of formatting in their text, it will replace the identifiers with the contact name of the person that their identifier maps to.
In both cases, it sounds like the name of the participant should be showing up rather than their phone number.
I tried updating my contact’s number to look exactly like the one that’s being output (I.e. “+1” in front), but it’s still showing the phone number rather than the name.
Does the API no longer show names, or am I doing something wrong?
We have a database logic, which sends text messages to phone numbers using webservice. Part of the messages is the string "X.net", which is a brand name. However in the telephones when the message is received this gets transformed into an URL and gets blue letters and gets underlined (because of the ".net"). We would like to avoid this, and instead present this as a simple text. Is there any possibility to do this, and if yes, how?
How can I validate emailid and mobile no both in a single input box in AngulaJS?
I'm trying to validate emaild and mobile no in same input box. it is working fine seperately, but for both emaild and mobile it doesn't work.
If you wish to verify the input using AngularJS (not the safest way to do it if it's the only check, making a second check in PHP/back-end/server side is recommanded).
You can use regular expression to filter the email and the phone number. You might want to check out ng-pattern
AngularJS Official documentation page
Emails and AngularJS: https://docs.angularjs.org/api/ng/input/input%5Bemail%5D
Example: https://jsfiddle.net/txtuz2xn/4/
Phone number will vary from a country to another. Up to you to see how you want your regex to go.
If you want to have 1 input that checks either the phone or the email you could set up $scope.regex1 = ... and $scope.regex2 = ... and check regex2 if regex1 fails.
I try to get and analyse data from text with the Twilio API. With their example, I can get the phone number from the text is sent, but I would like to get the datetime and the body of the message.
For the phone nmber you just have to use that:
$phone = $_REQUEST['From'];
It works also for To and Body but I tried with DateSent and it's not working.
$date = $_REQUEST['DateSent'];
Do you have an idea about what could be the word to get it?
According to the Twilio Docs the date is not sent as a parameter. However, you can use the Rest API to retrieve the SMS using the $_REQUEST['SmsSid'], and the returned data will contain a DateCreated.
Note: As John commented, unless you really need the 'official' timestamp, it's essentially the current time. Also note that if you try to query the API for a message that just came in, it may not have propagated, so you may not not get the data you're requesting.
If there's some use case where you can't just use the current timestamp, that would be interesting.
I understand that text_field creates an input field of type text, while email_field creates an input field of type email.
But, what is the difference between these two input types ?
Say I have a client model while a client has an email. Should I use email_field here ?
The email field is the new html 5 input which right now behaves the same on most of the machines with the exception of a few mobile devices such as the iphone where it switches to a different keyboard.
You can find more about it by googling html5 email field.
It's just a touch of finesse which some users will appreciate.