I’m looking to find a way to force field validation on 3 different fields on my page:
Phone Field: XXXXXXXXXX (must be 10 numeric values only)
Zip Code: XXXXX (must be 5 numeric values only)
DOB: must be MM/DD/YYYY format only
Help!!
I’m looking to find a way to force field validation on 3 different fields on my page:
Phone Field: XXXXXXXXXX (must be 10 numeric values only)
Zip Code: XXXXX (must be 5 numeric values only)
DOB: must be MM/DD/YYYY format only
Help!!
Sure thing, so I will first answer your last question 😉
There is absolutely a way to duplicate a page. In your page overview within the section titled “A/B Test Center” select the gear dropdown ⚙️ then select “duplicate this variant.”
#1) I’m pretty sure you have it right. As long as the number has a legitimate area code and listing, then it is considered valid. “612)323-8016” may have confusing characters but it is a still a legit phone number sequence.
#2) Field names are shown in the properties tab, but you can’t make the changes there. I have pointed out the area where you can edit field names in the form designer. Once you select the field you wish to edit of course (I just used your screenshot as an example)
Yes, to “Add New Javascript.” I would recommend adding both of these scripts in the same “script” area. So call this new added script “Date of Birth & Zip Code Validation.” Before Body End Tag should work just fine. If you copy and paste those scripts exactly as they are, you should be all set.
Make sure you include both the open and close tags, like this…
<
script>
blah blah
date of birth code stuff code stuff in here
<
/script>
<
script>
blah zipcode stuffs in here…
<
/script>
Then boom, done! Let me know if you get it working!
Thank you Kyle. A few follow up questions on this:
1 - Phone Number Validation, in reviewing the setup of this field, it appears that the field is currently set to validate based on North American phone numbers, so I’m not sure why these fields specifically would pass through… for example:
Is there someway where I can create a duplicate of this page to test these changes? I certainly don’t want to break anything on the active form I’m using.
Please let me know!
Appreciate your help!
Hey there,
So the pre-definded Phone Number field has an option to validate based on the country you need.
To validate zip and dob, you will need to add some javascript.
Here is a solution to validate zipcodes.
And you will need to make sure your form field name is “zip_code”
Here is the solution to validate Date of Birth where I’ve just made a few edits to the first zipcode script. You will want to make sure your DOB field name is “date_of_birth”
<
script>
lp.jQuery(function() { var ruleID = 'dob' var field = 'date_of_birth'; var message = 'Please enter a date in this format: MM/DD/YYYY'; var rules = module.lp.form.data.validationRules[field]; .validator.addMethod(ruleID, function(value, field) {
var valid = /^([0-9]{2})/([0-9]{2})/([0-9]{4})$/.test(value);
return valid || (!rules.required && !value);
}, message);
rules[ruleID] = true;
});
</script>
Hopefully you feel comfortable adding scripts, let me know if you have some questions 🙂
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.