previous | index | next

The Callback Function

The response is either "okay" or an error message.

The processRealtimeValidation JavaScript callback function must check the response and either show the error in the DIV or hide the DIV:

      function processRealtimeValidation(xhr) {
          var rt = xhr.responseText;
          if(xhr.responseText == "okay") {
              hideErrorsDiv();
          }
          else {
              showErrorsDiv(rt);
          }
      }

      function hideErrorsDiv() {
         var errors = $("errors");
         errors.innerHTML = "";
         errors.style.display = "none";
         errors.style.padding = "0px";
         errors.style.border = "none";
         errors.style.fontSize = "0em";
      }

      function showErrorsDiv(msg) {
         errors.style.display = "inline";
         errors.style.color = "red";
         errors.style.padding = "10px";
         errors.style.border = "thin solid red;";
         errors.style.fontSize = "1.5em";
         errors.innerHTML = msg;
         Fat.fade_element("errors", 60, 150, "#FF0000", null);
      }

previous | index | next