Solved

Change the color of the required field asterisk (*) in form fields labels

  • 5 July 2023
  • 5 replies
  • 88 views

Badge

Hello, I want to change the color of the required field Asterisk (*). I want to to be a different color rather than the default color. Could anyone can help me with that??

icon

Best answer by Nayon 6 July 2023, 09:53

View original

5 replies

Userlevel 2
Badge +1

Hi,

You’ll need a small piece of code to change the default color of the required field Asterisk (*)

First, make sure you have jQuery added to your page.

Now, put this code as a new script on the javascript tab with placement “Before Body End Tag

<script>
$("label").each(function() {
var text = $(this).text().replace(/\*/g, "<span class=\"asterisk\">*</span>");
$(this).html(text).find(".asterisk").css("color", "#0098db");
});
</script>

 

Change the color code inside the " " on the snippet to your liking and it should appear as the color of the required field Asterisk (*)

 

Live Example of swapping the default color of Asterisk on form fields

Userlevel 4
Badge

Wow! Thanks @Nayon

Just tried it out and it works perfectly. 😎

Userlevel 2
Badge +1

Wow! Thanks @Nayon

Just tried it out and it works perfectly. 😎

My pleasure, always happy to help 😃

Badge

Thanks a lot @Nayon!

It works perfectly. 

 

Userlevel 2
Badge +1

Thanks a lot @Nayon!

It works perfectly. 

 

Glad it helped

Reply