Forced Field Validation



Show first post

53 replies

Userlevel 5

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)

Inkedimage_LI2

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:

  • 612)323-8016
      1. 4160
  • 715 616–2701
  • 18052601027
    Is this validation looking at the number of integers provided and ignoring spaces, periods, commas, parentheses?

  1. As for the date or birth and zip code fields, I’d just like to confirm the process in which I need to make your suggested updates (apologies as I am a novice with setting up a webpage):
    - Under the properties tab, change the Field Name to:
    - “date_of_birth” (currently set as “dob”)
    - “zip_code” (currently set as “zipCode”)
    - Then select “Add New Javascript”
    - Script Name - ex. “Date of Birth Validation”; “Zip Code Validation”
    - Placement - I’m not sure of the appropriate selection here, can you advise? (I would
    think it should be “Before Body End Tag”)
    - Copy/Paste the provided scripts as appropriate
    - Save Code

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!

Userlevel 5

Hey there,

So the pre-definded Phone Number field has an option to validate based on the country you need.
Capture

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 🙂

Reply