Jan 26, 2016, 9:30 AM
10 Posts

Change field color back to original when it is valid

  • Category: Other
  • Platform: Windows
  • Release: 9.0.1
  • Role: Developer
  • Tags:
  • Replies: 1


The following JavaScript code changes the field's background color and border color if it is invalid for fields that are required and were not filled in.   It works as expected when I submit the form without entering a value in the required field.  I was hoping to add code to change the field back to normal after the user submits the form and the field has a value.  However, I still would like to change the other required field if they were left blank.

I apologize in advance if I don't make any sense.  Let me know if I need to explain things further.

The following code is in a JavaScript library.

XSP.validationError= function validationError(clientId,message) {



var e = this.getElementById(clientId);

if(e!=null) {

e.style.background = "lightyellow";

e.style.border = "1px solid red";











Jan 30, 2016, 2:32 PM
453 Posts
An Idea

If I understand the problem correctly I think you need to do an else on the if(e!=null)

something like 

if (e!=null) {

//is invalid set field colors


//is valid revert to original color