FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



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

Hello,

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) {

hidePleaseWait();

this.error(message);

var e = this.getElementById(clientId);

if(e!=null) {

e.style.background = "lightyellow";

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

if(e.select){

e.select();

}

if(e.focus){

e.focus();

}

}

}

 

 

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

}else{

//is valid revert to original color

}

 


FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.