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

Question

Question

Label Color in Collection When Required

asked on August 20, 2018

I have seen a couple of posts and found the JavaScript below to change the color of the field label only when the field is required.

 

$(document).ready(function () {
2
  $('.cf-required').parent().css('color', '#cd2026');
3
});

 

This has been working well for me until I tried to put required fields in a collection.  The first set of fields gets colored labels but any additional sets don't get colored labels.  Ideas on how I would get all the additional sets to be colored?

requiredcollection.png
0 0

Answer

SELECTED ANSWER
replied on August 20, 2018

You need to make the browser check for required fields whenever the 'Add' button is clicked. My modified function below has an additional function that checks for this:

$(document).ready(function () {
  $('.cf-required').parent().css('color', '#cd2026');
  
  $('a[ref-id="q20"]').click(function() {
  	$('.cf-required').parent().css('color', '#cd2026');
  });
});

Replace "q20" with the qN associated with the "Add" button. For example, in the following screenshot, the browser's Inspect tool shows the value of ref-id for that button:

1 0
replied on August 20, 2018

Thank you so much.  Works perfect.

0 0

Replies

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

Sign in to reply to this post.