Hi All,
We use forms asking for Phone Numbers from our customers in the landing pages that we publish.
The details of the label are -
Label Name: Phone Number
Marketo Field: Phone Number
Field Type: Telephone
Right now the field accepts phone numbers even if they are not 10 digits long
I wanted to keep a check on the backend (despite the validation message that I am showing to the LP viewers) so that only 10 to 13 digit numbers are accepted.
Could you guys help me out with this?
Thank You
regards,
-Prabash.
I think you will need some javascript to manage this field on the page level so that it cannot be submitted without the proper format
I think you will need some javascript to manage this field on the page level so that it cannot be submitted without the proper format
It sounds to me like @Prabash is validating on the client side but is concerned about people skipping validation.
Right now the field accepts phone numbers even if they are not 10 digits long
I wanted to keep a check on the backend (despite the validation message that I am showing to the LP viewers) so that only 10 to 13 digit numbers are accepted.
Could you guys help me out with this?
Server-side validation is going to require a webhook -- a simple webhook, but nevertheless one that can do more than a flow. Rajesh Talele Aruba Prod can surely hook you up via his managed webhook service.
But I'm not convinced of the need for phone number validation alone. If you have people bypassing client-side field validation, surely they are putting invalid data into other fields as well. If you are having widespread problems with people bypassing validation you should roll out a ReCAPTCHA on your form.
Thanks Sanford. Appreciate it.
Prabash,
See if the 'web hook service' at Web Hook Library can help.
This particular web hook service is free to use.
Rajesh
Hi,
I am currently doing this by the following workaround:
Field Type: Number (changed from Telephone)
And in the restrictions section, I define my minimum and maximum number values to be accepted. Let's say I want to accept phone numbers only ranging from 10 to 11 digits; then:
Minimum Number: 1000000000
Maximum Number: 99999999999
This ensures that digits coming into my Phone Number field only range from 10 to 11 digits only
Thanks!
Regards,
Prabash..
Thanks, Prabash -
I tried the solution but not sure about its results.The field appears with scroll arrows and clicking them displays the minimum number value. Please see here.
Any info appreciated.
Thanks!
There are 2 totally different questions here.
The original question is about verifying on the back end -- that is, even if someone maliciously posts invalid data by skipping JavaScript validation -- that the field contains between x and y digits.
The above solution (curiously posted by the same person who was originally talking about the back end?) is a client-side validation that can just as easily be bypassed as the built-in phone validation.
If you want between 10 and 13 digits, I would start w/a Text field with the Mask Input 9999999999999. That takes care of the digits and the maximum length. Then do the minimum length check in JS.
MktoForms2.whenReady(function(form){
form.onValidate(function(native){
if (!native) return;
var currentVals = form.getValues(),
phoneField = 'Phone',
RE_PHONE = /^\d{10,13}$/;
form.submittable(false);
if( !RE_PHONE.test(currentVals.phoneField) ) {
alert('Too many or not enough digits');
} else {
form.submittable(true);
}});
});