Change background-color textentry field in a form | Experience Community
Skip to main content
Solved

Change background-color textentry field in a form

  • Sep 17, 2018 11:07 AM UTC
  • 6 replies
  • 99 views

Nico_Leussink
Level 2 ●●
Forum|alt.badge.img+5
Hello, In a survey I build in a form like the below screenshot: ! On the field Zipcode I added a validation on Postalcode. If a wrong code is given, a message appears. But I also want to have a different background-color. How can I set this background-color to a bit of red? Thanks in advance.

Best answer by LaT

@Nico_Leussink ; jQuery("[id='QR~"+this.questionId+"~4'] ").css({"background-color":"red"});
View original

6 replies

PeeyushBansal
Level 7 ●●●●●●●
Forum|alt.badge.img+53
  • Level 7 ●●●●●●●
  • Sep 17, 2018 12:17 PM UTC
Do you want to set it permanently red or become red only on wrong entry.

LaT
Level 2 ●●
Forum|alt.badge.img+1
  • Level 2 ●●
  • Answer
  • Sep 17, 2018 12:20 PM UTC
@Nico_Leussink ; jQuery("[id='QR~"+this.questionId+"~4'] ").css({"background-color":"red"});

Nico_Leussink
Level 2 ●●
Forum|alt.badge.img+5
  • Author
  • Level 2 ●●
  • Sep 17, 2018 12:22 PM UTC
@bansalpeeyush29 : I would like to have it red when wrong and default color when correct. Is such possible?

PeeyushBansal
Level 7 ●●●●●●●
Forum|alt.badge.img+53
  • Level 7 ●●●●●●●
  • Sep 17, 2018 12:23 PM UTC
Default you can set as per @LaT while on error it seems difficult.

PeeyushBansal
Level 7 ●●●●●●●
Forum|alt.badge.img+53
  • Level 7 ●●●●●●●
  • Sep 17, 2018 12:40 PM UTC
You can have look at below code https://www.oreilly.com/library/view/javascript-cookbook/9781449390211/ch14s04.html

Nico_Leussink
Level 2 ●●
Forum|alt.badge.img+5
  • Author
  • Level 2 ●●
  • Sep 17, 2018 12:41 PM UTC
Thank you all, this helped me a lot.