validation for email and mobile no in single inputbox using angularjs - angularjs-ng-pattern

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.

Related

ruby on rails how to input text into a website after using Nokogiri to open it

I'm writing a unit test for our app for the forget password mutation. The mutation will send the email with the new randomly generated password to the provided email address, and I want to test this. Right now I'm using this to access yopmail.com
doc = Nokogiri::HTML(open("https://yopmail.com/en/"))
puts doc.to_html
On yopmail.com, there's an input box where u input the disposable email to get to the inbox, I just want to know how I would input the disposable email that I generated in my code into yopmail using Nokogiri or whatever other means. Sorry if the explanation isn't clear, I'm not sure how to make this completely make sense. Thank you.
As TTD already mentioned, Nokogiri can only parse HTML / XML but you can't really control the input (although you can alter the HTML itself but that doesn't help for your problem).
What I would do is to avoid entering user input as it will also make your tests a lot more flaky. You can get your mailbox for instance with https://yopmail.com/?<name-of-your-inbox> so you don't have to enter any input.
Unfortunately, yopmail seems to not offer any API. If you're not bound to yopmail, you could for instance try https://rapidapi.com/Privatix/api/temp-mail which offers an API and it make it easier to parse the email results.

What number formatting does a mobile phone can call?

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.

Testing email markup against myself not working

I've used this schema example and sent myself an email using the Email Markup App Script.
The mail is recieved but no Event card is shown. I've also validated it with the Google Markup Validator, and I'm not missing any required field. What am I doing wrong?
PD: Only "Action" markup worked for me.
#whitenoisedb I see that you've tried sending the lodgingreservation schema to yourself. If you're copying and pasting the example without modifying the checkinDate and checkoutDate attributes, your card will not generate until 2017.
"checkinDate": "2017-04-11T16:00:00-08:00",
"checkoutDate": "2017-04-13T11:00:00-08:00"
Use a current checkinDate (ex. 2015-12-15T16:00:00-08:00) instead.
If the dates are coming up soon and it is still not showing, there is a chance that this type of Google cards are not supported in your country

Checking user's input and disallowing certain words

I have created a text input in which the user can input a website. However I want to disallow specific domains.
At first I want to be able to check if the input(domain, e.g. google.com) matches a specific word (e.g. google) - (I will later create a domains' blacklist).
In the controller (Rails) I want to check the input first before saving the object.
Any clue how can I check the input for a specific word?
You could do that in regexp but there is a gem that is compliant to several rfc that would suit you better:
https://github.com/sporkmonger/addressable#example-usage
You can try this
URI("http://www.google.com/").host =~ /google/
Here you can iterate through you blocked list of domains and can check above condition for each blocked domain.

Rails: How "email_field" differs from "text_field"?

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.

Resources