You are viewing limited content. For full access, please sign in.

Question

Question

Is it possible to hide text being added via JavaScript along with a field rule?

asked on July 15, 2020 Show version history

Due to the limitations of currency fields, I have a few number fields which I have set up in a way to mimic the look of a currency field. This is the JavaScript I'm using to populate the dollar sign to the left of the field:

$(document).ready(function() { 
  $('#q286').before("$");
});

One issue I'm running into though is that if I hide that field via field rules, the dollar sign still remains. Is there any way I can revise the code to allow the dollar sign to be hidden along with the field and only display when the field is also visible?

0 0

Replies

replied on July 16, 2020

You use number field because of what limitation of currency field?

0 0
replied on July 16, 2020

Well, I've since learned a bit more about what is needed with the form and I'm not sure what I was planning will work anyway, but the limitation (at least with the default field type) is that I cannot set a range. I need to determine the upper limit of a currency field dynamically based on the calculated result of another field.

Initially I just needed to set an upper limit which is why I opted for a number field over a currency field, but now that I've learned I need to dynamically adjust that limit, I feel like JavaScript will be needed so the field type will be irrelevant.

0 0
replied on July 22, 2020

Thanks for sharing, supporting configure allowable range for currency is already in our feature requests list. 

1 0
replied on July 16, 2020

Hi Dylan,

Try "#q286 input". Currently you're putting it before the whole element as opposed to the field within the element.

FYI you can also do this with CSS:

#q25 .cf-field:before {
  content: "$";
}

 

0 0
replied on July 16, 2020

Thank you Jim! I'm becoming much more familiar with CSS than I am JavaScript so I appreciate that this is doable within CSS, haha.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.