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

Change background-color textentry field in a form

  • September 17, 2018
  • 6 replies
  • 79 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"});

6 replies

PeeyushBansal
Level 6 ●●●●●●
Forum|alt.badge.img+44
  • Level 6 ●●●●●●
  • September 17, 2018
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
  • September 17, 2018
@Nico_Leussink ; jQuery("[id='QR~"+this.questionId+"~4'] ").css({"background-color":"red"});

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

PeeyushBansal
Level 6 ●●●●●●
Forum|alt.badge.img+44
  • Level 6 ●●●●●●
  • September 17, 2018
Default you can set as per @LaT while on error it seems difficult.

PeeyushBansal
Level 6 ●●●●●●
Forum|alt.badge.img+44
  • Level 6 ●●●●●●
  • September 17, 2018
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 ●●
  • September 17, 2018
Thank you all, this helped me a lot.