Forced Field Validation

#6

There is an option to see what your page looks like in the builder.

Look in the top right area of the window for… “:eye: Preview”

That will allow you to see your selected variant before it’s live. But sometimes I’ve noticed scripts that don’t fire off in the preview. It’s always best to test things like this from the live URL. If you need to do that, just add 100% of your traffic to the new variant from the overview page. This way you know you will land on the proper variant to test.

0 Likes

#7

Will I run the risk of the traffic hitting the new variant/page that isn’t setup correctly though? Or I am misunderstanding what you are saying? Basically, I’d like to just run some test leads through the new variant without it affecting traffic on the existing variant. Thoughts?

0 Likes

#8

Oh I see,

Perhaps then set up a new “test” page that isn’t tied to anything else like your domain and add that variant to it.
Unbouncepages.com/my-test-page”

I think there is an option to create a new page from variant or something along those lines to make things easier.

0 Likes

Form field date format
#9

Great, thanks! I created a test page off of that variant I created.

http://www.disabilitybenefitnetwork.com/ssd-test-page/

However, the DOB doesn’t appear to be throwing up an error when an incomplete DOB is entered. Any idea what might be wrong there?

0 Likes

#10

Ah sorry @blynch1712,

When I pasted the dob script here in the community it removes some characters! :grimacing:
I guess that’s why it’s safer to go with github.

Replace the former dob script with this one here.

0 Likes

#11

Hi Kyle - when signing back in to unbounce to retest my test URL, I can’t seem to find it. Again, probably a silly question, but can you point me in the right direction? I created the new test URL but it’s not showing as existing and I did initially publish it to test. The URL is still published because I can look at it directly.

http://www.disabilitybenefitnetwork.com/ssd-test-page/

Thoughts?

0 Likes

#12

Sorry, I need some clarification…so you can’t find the page you have been working on in your Unbounce account?

0 Likes

#13

Correct. When signing in I see the active page that I have directed traffic to and the SSD Copy I initially created off the original. However, the new variant I created with the URL: http://www.disabilitybenefitnetwork.com/ssd-test-page/ to specifically test outside of any traffic, I cannot seem to find in the unbounce interface. Thoughts?

0 Likes

#14

Well I really doubt that it’s gone, unless you consciously selected to delete the page or “discard” the variant and then click again to “delete” the variant.

Let’s start with clarifying the difference between a page and a variant in Unbounce. A single page can have multiple variants in which all the variants point to the same URL, based on the weight you assign them.

Surly, your “SSD Copy” page has the variant that you have been working on within it.

These are pages

Capture

These (highlighted) are variants

Capture2

0 Likes

#15

It was a filtering issue. Found the page.

I did make the updates on the SSD Test Copy page and tested it and all is working correctly. I copied the code over to the page I’m running traffic to and it’s not working there. I saved and republished and cleared my cache and I’m not seeing the errors on either the DOB or the Zip Code field. I went back and resaved a second time and I’m still not having any luck. Is there any further updates I need to make? Thoughts?

0 Likes

#16

If you provide the URL to the page you run traffic to, I can look and see what may be going wrong.

Alternatively as a work-around, you could move your “SSD TEST Copy” variant and add it to the page you run traffic to, then point everything to that variant :wink:

0 Likes

#17

Thanks! The variant I am pointing traffic to is http://www.disabilitybenefitnetwork.com/application/

I’d prefer to update the javascript on that page, so let me know if you can figure out what the issue is. Let me know if you need any further info. Thanks again!

0 Likes

#18

@blynch1712

Your Date of Birth field name and ID is “dob” and it needs to be “date_of_birth”

0 Likes

#19

Hi!
The work email is working just fine!
But is there a way to valid a text form an array?
Example: Show error message when the text is not “text 1” or “text 2” or “text 3”

Thanks!

0 Likes

#20

Hi Kyle! How can I validate to allow just 3 digit number?

0 Likes

#21

I’ve made some edits to the var valid…The script below should work. You can change the field name and message as needed in your case.

< script>
lp.jQuery(function() {
var ruleID = 'dob' var field = 'date_of_birth';
var message = 'Please enter a date in this format: 123';
var rules = module.lp.form.data.validationRules[field];
.validator.addMethod(ruleID, function(value, field) {
var valid = /^([0-9]{3})$/.test(value);
return valid || (!rules.required && !value);
}, message);
rules[ruleID] = true;
});
</script>
0 Likes

#22

Thanks so much Kyle! I do not what I am doing wrong. It is not working. This is what is showing in the webpage after I add the script.

0 Likes

#23

Ah I see what you need. That requires a more detailed line of regex. Replace that var valid with the following and it will work for number between 20 and 500.

var valid = /(?<!-)\b([2-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|3[0-9][0-9]|4[0-9][0-9]|500)\b/.test(value);

I’m a bit of a rookie with regex logic so let me know if that works on your page!

1 Like

#24

Thanks Kyele! Somebody from the group pass me a script. It is working great. The script is:

<script>
  
  lp.jQuery(function($) {
  
    var ruleID = 'custom';
    var field = 'number';
    var message = 'Please enter a valid number';
  
    var rules = module.lp.form.data.validationRules[field];
  
    $.validator.addMethod(ruleID, function(value, field) {
  
      var valid = ( /^([2-8][0-9]|9[0-9]|[1-4][0-9]{2}|500)$/.test(value) );
  
      return valid || (!rules.required && !value);
    }, message);
  
    rules[ruleID] = true;
  
  });
</script>
1 Like

#25

Perfect! Glad you got it working :slight_smile:

0 Likes