How can I exclude/block yahoo.com domain during jquery form validation?

I’m new to jQuery and hope someone can point me in the right direction. I’m tring to validate a web form and return a message to the visitor that a business address is required. I would like to block yahoo, hotmail, gmail and aol domains. I found the ‘accept:’ method, but is there an "exclude:’ or something simular? here is the code I have:

$(document).ready(function () {                                                                                        
  $("#webform").validate({
    errorPlacement: function(error, element) {
      error.appendTo( element.parents("div.field:first").find("div.clear:first") );                                                        
    },
    onfocusout: false,
    onkeyup: false,
    onclick: false,
    debug: false,
    rules: {
        email_field: {
            required: true,
            email: true,
            accept: 'yahoo.com'
        }
    } // rules
  }); // validate
}); // function

Hi there,

And welcome to the forums.

I’m unaware of an “exclude” method, but it would be quite easy to code this up by hand.

This is what I would do:

$(document).ready(function(){
  // Custom validation rule
  $.validator.addMethod("checkDomain", function(value, element) {
    var evilDomains = ["yahoo", "gmail", "aol", "hotmail"];
    var domainEntered = value.replace(/.*@(.*)\\..*/, "$1");
    var isAcceptableDomain = true;
    
    if($.inArray(domainEntered, evilDomains) >= 0){
      isAcceptableDomain = false;
    }
      return this.optional(element) || (isAcceptableDomain);
  }, "Please use a sensible mail address");    
  
 $("#webform").validate({
    errorPlacement: function(error, element) {
      error.appendTo( element.parents("div.field:first").find("div.clear:first") );                                                        
    },
    onfocusout: false,
    onkeyup: false,
    onclick: false,
    debug: false,
    rules: {
      email : { checkDomain: true }
    } // rules
  }); // validate
}); // function

Hopefully the code is quite straight forward, but if you have any questions, just let me know.