CMS Development

Kamil_KK
Contributor | Platinum Partner
Contributor | Platinum Partner

input field validation

SOLVE

Hello All.

I am not really familiar with HubL, I would like to validate input field for presence of text in the banner headder, if there is a text apply styling (transparent background) , if there is no render just a banner. Something like that in JaveScript:

 
  const banner = document.getElementById("banner-text");

banner.children[0].textContent.length === 0 ?
banner.style.background = "none"  : false;
 
The ide is: thre is a e-mail template and user is able to apply Default text, so I wish to have the sytle depend on presence of thxt or lack of it.
I would appreciat help.
 
Best regards.
0 Upvotes
1 Accepted solution
Solution
Anonymous
Not applicable

input field validation

SOLVE

You'd probably want to use something like this:

{% if widget_data.product_names.value %}
<div class="coupon-ad">
<h3>For a limited time, get 50% off {{ widget_data.product_names.value}}! </h3>
</div>
{% else %} {% endif %}

Further information is available here: https://designers.hubspot.com/docs/hubl/if-statements

View solution in original post

2 Replies 2
Solution
Anonymous
Not applicable

input field validation

SOLVE

You'd probably want to use something like this:

{% if widget_data.product_names.value %}
<div class="coupon-ad">
<h3>For a limited time, get 50% off {{ widget_data.product_names.value}}! </h3>
</div>
{% else %} {% endif %}

Further information is available here: https://designers.hubspot.com/docs/hubl/if-statements

Kamil_KK
Contributor | Platinum Partner
Contributor | Platinum Partner

input field validation

SOLVE

Hello @Anonymous 

Thak you I guess this will do!

Cheers.

0 Upvotes