Form is showing message "PLEASE COMPLETE THIS REQUIRED FIELD" on page load

SOLVE
Occasional Contributor

Hi all,

 

We have a problem with the form on this page https://oni.bio/contact

 

When the first name is set as a required field the message "PLEASE COMPLETE THIS REQUIRED FIELD" displays straight away underneath the form field, even when the field hasn't been activated.

 

It's strange because the email required field works fine.

 

It seems to be a javascript issue but I'm not sure how to resolve the issue.

 

Any help is much appreciated!

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Highlighted
Regular Advisor | Gold Partner | HubSpot Certified Trainer

@DanBQ -

I suspect it's the code in this file https://oni.bio/assets/js/hub-spot-60481bcb94.js#

$('input[name="firstname"]').val('').change();

Can you comment that line out and let us know if the form first name field is prefilled with some sort of values.

I think what's happening is this:

There is a value and your code is doing a focus and blur event on form load. This might not affect the email field because the focus and blur events only trigger the HS error messages if there is a value in the field, you then focus the field, then clear it out, then blur. Since email might be empty, it doesn't follow that pattern.

Reply
0 Upvotes
1 Reply 1
Highlighted
Regular Advisor | Gold Partner | HubSpot Certified Trainer

@DanBQ -

I suspect it's the code in this file https://oni.bio/assets/js/hub-spot-60481bcb94.js#

$('input[name="firstname"]').val('').change();

Can you comment that line out and let us know if the form first name field is prefilled with some sort of values.

I think what's happening is this:

There is a value and your code is doing a focus and blur event on form load. This might not affect the email field because the focus and blur events only trigger the HS error messages if there is a value in the field, you then focus the field, then clear it out, then blur. Since email might be empty, it doesn't follow that pattern.

Reply
0 Upvotes