Lead Capture Tools

ekt
Teilnehmer/-in

Change error messages using JS

lösung

I need to change error messages for my form and I don't have an opportunity to use raw html for form, only iFrame. 

When I'm writing js-code for it in the console - everything is working, but when I'm adding js-code to the page (like a separate file or before closing <body> or to the setting of all pages) - it's not working. I can see this code in developer tools, but it works only when I'm copying it to the console. 

Is there any chance to fix it? 

 

Here is the code

$( document ).ready(function() {
$('.subscribe-form-wrapper .hs-form-iframe').contents().find('.hs-error-msg').css('display', 'none');
$('.subscribe-form-wrapper .hs-form-iframe').contents().find('.hs-error-msgs .hs-main-font-element').text('Please, share your work email with us');
});

 

0 Upvotes
1 Akzeptierte Lösung
Bryantworks
Lösung
Autorität | Diamond Partner
Autorität | Diamond Partner

Change error messages using JS

lösung
6 Antworten
Bryantworks
Autorität | Diamond Partner
Autorität | Diamond Partner

Change error messages using JS

lösung

Hey @ekt 

 

Due to the way the forms are rendered, you would have to use the embed code to enable this functionality.  This embed function is available on all tiers of HubSpot:

 

Forms _ HubSpot - Google Chrome 2019-06-18 08.18.27.png

 

Hope this helps!

Chris Bryant | Your Dedicated HubSpot Expert
0 Upvotes
ekt
Teilnehmer/-in

Change error messages using JS

lösung

Thanks, but still it's not working 

0 Upvotes
Bryantworks
Autorität | Diamond Partner
Autorität | Diamond Partner

Change error messages using JS

lösung

Hey @ekt 

 

Have you checked out how to customize the form embed code?  You might find your answer here.  

Chris Bryant | Your Dedicated HubSpot Expert
0 Upvotes
ekt
Teilnehmer/-in

Change error messages using JS

lösung

Thanks)
I've found another solution - to use setInterval. It's not a perfect approach so with a client we've decided to leave messages as they are.

 

But now I need to style these messages - is it possible using only css? (the form is in an iframe)

 

0 Upvotes
Bryantworks
Lösung
Autorität | Diamond Partner
Autorität | Diamond Partner

Change error messages using JS

lösung

Yes, that is possible via CSS, you can read more about it here:  https://knowledge.hubspot.com/articles/kcs_article/forms/how-do-i-style-my-embedded-form

Chris Bryant | Your Dedicated HubSpot Expert
ekt
Teilnehmer/-in

Change error messages using JS

lösung

thanks for help!

0 Upvotes