Validating Phone Number Fields


One of the pre-programmed fields in the “Forms” option is for a phone number. The only problem is, you can validate it as an email address. Can we get an option to validate a phone number field as a phone number, either xxx-xxx-xxxx or as yyyyyyyyyy, either way as long as it’s consistent?


15 replies

Yes, we will be adding the ability to validate a field as a North American format phone number soon.

we need the abilility to validate an Australian Phone Number too

format is:

Phone; (xx) xxxx xxxx or xxxxxxxx
(xx) = area code

or Cell Phone: xxxx xxx xxx )or without spaces)

Wouldnt it be easiest to simply allow the user to stipulate how many digits the field must contain?

Wufoo.com allows this with specified fields, and it works well for validating phone numbers.

If not -we need U.K. validation too : ) !

anything here??

It would be great to have this as a setting in UnBounce, as a system used around the world, defaulting to the american format doesn’t feel right.

While I understand the reason for the validation function, I’d prefer no validation by default, as my customers are based around the world with many different number formats.

Luckily I check and test my pages many times before publishing, but if I ever forgot to un-tick that box, it could result is lost revenue and missed leads.

What is going on here? We have been waiting for over 12 months now!

Never thought this before but seriously thinking of jumping ship.

STILL NOTHING?? wow!

we need the abilility to validate an Australian Phone Number too

format is:

Phone; (xx) xxxx xxxx or xxxxxxxx
(xx) = area code

or Cell Phone: xxxx xxx xxx )or without spaces)

Need to validate Brazilian Phone N.

Just like australian.

(xx) xxxx xxxx

Hey guys, we have added support for UK, Australian and Generic phone number validations in addition to North American like we’ve always had. You can see my detail response over here…

Hi there! we had a similar problem but we find this code and it works for us, so now we can “customize” a bit the telephone validation and others validations like postcode.

Hope s.o. find helpful, for us it is.

<br />(function(e){function t(){var t=window.module.lp.form.data;var n=t.validationMessages;var r=t.validationRules;this.changeTitle=function(n){e(function(){e("#"+t.errorContainerId).find("div.error").text(n)})};this.changeField=function(e,t,i){if(!n[e])return;n[e].required=t;if(i&&r[e].email)n[e].email=i;if(i&&r[e].phone)n[e].phone=i}}window.errors=new t(lp.jQuery)})(lp.jQuery)<br />&nbsp;&nbsp;<br />// Change the title bar of the validation error box<br />errors.changeTitle("Por favor, corrige los errores:");<br />// Change the error text for specific fields. The first message is shown when nothing is<br />// entered and the second is shown when an invalid email/phone number is entered.<br />errors.changeField("nombre", "Por favor, escribe tu nombre");<br />errors.changeField("email", "Por favor, escribe tu email", "ÁVaya! Parece que no has escrito bien tu email...");<br />&nbsp; //errors.changeField("telŽfono", "Por favor, escribe tu nœmero de telŽfono", "ÁVaya! Parece que no has escrito bien tu nœmero de telŽfono...");<br />&nbsp; //errors.changeField("c—digo_postal", "Por favor, escribe tu c—digo postal"),"ÁVaya! Parece que no has escrito bien tu c—digo postal...");<br />&nbsp;<br />&nbsp;<br />var digitsConfig = {<br />&nbsp; rules: {<br />&nbsp; &nbsp; required: true,<br />&nbsp; &nbsp; digits: true,<br />&nbsp; &nbsp; minlength: 9,<br />&nbsp; &nbsp; maxlength: 9,<br />&nbsp; },<br />&nbsp; messages: {<br />&nbsp; &nbsp; required: "Por favor, escribe tu nœmero de telŽfono",<br />&nbsp; &nbsp; digits: "ÁVaya! Parece que no has escrito bien tu nœmero de telŽfono...",<br />&nbsp; &nbsp; minlength: "ÁVaya! Parece que no has escrito bien tu nœmero de telŽfono...",<br />&nbsp; &nbsp; maxlength: "ÁVaya! Parece que no has escrito bien tu nœmero de telŽfono...",<br />&nbsp; }<br />};<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />window.module.lp.form.data["validationRules"]["telŽfono"] = digitsConfig["rules"];<br />window.module.lp.form.data["validationMessages"]["telŽfono"] = digitsConfig["messages"];&nbsp;<br />console.log(window.module.lp.form.data);<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;<br />&nbsp; var digitsConfig2 = {<br />&nbsp; rules: {<br />&nbsp; &nbsp; required: true,<br />&nbsp; &nbsp; digits: true,<br />&nbsp; &nbsp; minlength: 5,<br />&nbsp; &nbsp; maxlength: 5,<br />&nbsp; },<br />&nbsp; messages: {<br />&nbsp; &nbsp; required: "Por favor, escribe tu c—digo postal",<br />&nbsp; &nbsp; digits: "ÁVaya! Parece que no has escrito bien tu c—digo postal...",<br />&nbsp; &nbsp; minlength: "ÁVaya! Parece que no has escrito bien tu c—digo postal...",<br />&nbsp; &nbsp; maxlength: "ÁVaya! Parece que no has escrito bien tu c—digo postal...",<br />&nbsp; }<br />};<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />window.module.lp.form.data["validationRules"]["c—digo_postal"] = digitsConfig2["rules"];<br />window.module.lp.form.data["validationMessages"]["c—digo_postal"] = digitsConfig2["messages"];&nbsp;<br />console.log(window.module.lp.form.data);<br />

Thanks for sharing this! I can see this being super useful for users. 

I think you are missing the point if the client wants to be contacted he will put the details in correctly. What you need to do is work on the message in your page so the client wants to talk with you. You can validate the form till the cows come home and if they don’t want to be contacted they will put rubbish in. Have fun

I can’t enter australian phone number. It says it’s not valid everytime I try! 

Hi Julia,

This  may be a silly question so forgive me if it is!  Have you set the phone number field to use the Australian phone number validation?  It defaults to the states and I’m in the UK so I have to make sure  I manually change each phone number field to UK in my form config. I could see it being easy to miss if you were not aware it was there.

If it’s still not working then feel free to ping a response back with a link to your landing page and I’d be happy to take a look for you. 

Cheers

Stuart.

What would be great is that the phone number field can be configured to be a National or International number. 

If it’s an international number, a dropdown should appear with the country codes in it, so the visitor can select the appropriate country code. 

We’re dealing with the same problem that we’re targetting businesses anywhere in the world, and do not have a decent way (without going to our development team) to validate the numbers entered. 

Reply