tags:

views:

15

answers:

0

Hi,

I have the following custom validation, it is requesting a function from the server and returns 0,1,2,3 & 4. Based on the result, I'd like to display error messages. This code below works if return is "1,2,3 & 4" but if it is "0", it seems that return true is not working. It doesn't submit my form and seems to loop or bubbling if I add alert. Can somebody share some idea what is wrong with my code?

$.validator.addMethod(
    "errorMessage",
    function() {
      var validator = this;  
   $.AjaxCFC({
      url: "Outage.cfc",
      method: "ConfHubNodes",
      data: {"div":sDivisionList, "hub":sHubList, "nodes": sNodeList},
      success: function(data)
      {
      sDumper(data); 
      if (data == 0) {
       alert('true');
       return true;
      }
      else {
       if (data == 1) {
        var msg = "Required: Please choose a hub associated with selected market(s).<br>";
        $('#errorMessage').addClass('errorMessage').html(msg);  
        return false;
       }
       if (data == 2) {
        var msg = "Required: Please choose a market associated with selected hub(s).<br>";
        $('#errorMessage').addClass('errorMessage').html(msg);      
       return false;
       }
       if (data == 3) {
        var msg = "Required: Please choose a node associated with selected hub(s).<br>";
        $('#errorMessage').addClass('errorMessage').html(msg);       
       return false;
       }
       if (data == 4) {
        var msg = "Required: Please choose a hub associated with selected node(s).<br>";
                   $('#errorMessage').addClass('errorMessage').html(msg);      
       return false;
       }
      } // end if statement                              
      } // end success
   }); // end ajax request   
    },
     ""

  );// end errorMessage