
<!-- WDSError methods to be redefined to have special UI behavior when errors -->

// -------------------------------------------------------------------------- \\
// WDSObjectError_modifySrcElement
//   you can redefine this method if you want something special for your UI
// -------------------------------------------------------------------------- \\
function WDSObjectError_modifySrcElement () {
  if (this.object) {
    var parent = getFirstAncestorByClassName(this.object);
    if (parent != null) {
      if(parent.className && parent.className!="") {
        parent.className += " ErrorBgrd";
      }
      else {
        parent.className = "ErrorBgrd";
      }
      var errorImg = document.getElementById("WDSErrorImg" + parent.id);
      if(!errorImg && this.object.id) {
        errorImg = document.getElementById("WDSErrorImg" + this.object.id);
      }
      if (errorImg) {
        errorImg.style.display = "";
      }
    }
  }
}

// -------------------------------------------------------------------------- \\
// WDSObjectError_initSrcElement
//   you can redefine this method if you want something special for your UI
// -------------------------------------------------------------------------- \\
function WDSObjectError_initSrcElement () {
  if (this.object) {
    var parent = getFirstAncestorByClassName(this.object);
    if (parent != null) {
      parent.className = parent.className.replace(/( *)ErrorBgrd/,"");
      var errorImg = document.getElementById("WDSErrorImg" + parent.id);
      if (errorImg) {
        errorImg.style.display = "none";
      }
    }
  } 
}

function getFirstAncestorByClassName(target) {
  var parent = target;
  var strTagName;
  var objectId = null;
  if(target.id) {
  	objectId = target.id;
  }
  while (parent = parent.parentNode) {
	  if (parent.tagName){
	  	strTagName = parent.tagName;
	  	//alert("parent.tagname = " + parent.tagName);
	    if (('TR' == strTagName.toUpperCase()) || ('TABLE' == strTagName.toUpperCase()) || ('TD' == strTagName.toUpperCase())){ 
	    	if (parent.id){
	    		if (parent.id.length > 0) {
	    			// The test on the value for id has been added for the search page. 
	    			// In fact in Pnext the error parent id has to contains the id of the field
	    			// If someone is having a problem please contact Nicolas Igot
	    			if((objectId && parent.id.indexOf(objectId)!=-1) || !objectId) {
	      			return parent;
	      		}
	      	}
	      }
	    }
        // Since HTML refactoring any type of element can be valid but it 
        // has to contain the objectId in its id.
        if(parent.id && parent.id.length > 0 && objectId && parent.id.indexOf(objectId)!=-1) {
          return parent;
        }
	  }
  }
  return null;
}
<!-- End WDSError methods to be redefined to have special UI behavior when errors -->
