Apologies in advance, I have zero programming knowledge.
So my company just bought some software that includes a checkout function. For some reason, the checkout page does not by default highlight which fields are mandatory vs optional in order to complete checkout.
My boss has asked to me highlight the mandatory fields, which can be done through javascript. Except I don’t know javascript.
The support guy helped me out, and I’ve been able to do most of it using the ‘contains’ function, like this:
$('.page-checkout label:contains(Country)').after(' <span class="required-text" style="color:red">* Required</span>');
But, I have some fields don’t have a unique enough label for the contains function to only highlight what I need (e.g. I want to highlight the mandatory "address" field, but not the optional "address 2" field).
How do I only target the "address" field without also hitting the "address 2" field?
2
Answers
Or perhaps using "not contains"?
You could amend the
:contains(Address)
with a:not(:contains(2))
. For example:This is maybe a more elegant way: