Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.59 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Edited / adapted from http://forum.jquery.com/topic/jquery-validate-comma-seperated-multiple-emails-validation#14737000002179275
  2. jQuery.validator.addMethod("multiemail", function (value, element) {
  3.     if (this.optional(element)) {
  4.         return true;
  5.     }
  6.  
  7.     var emails = value.split(','),
  8.         valid = true;
  9.  
  10.     for (var i = 0, limit = emails.length; i < limit; i++) {
  11.         value = emails[i];
  12.         valid = valid && jQuery.validator.methods.email.call(this, value, element);
  13.     }
  14.  
  15.     return valid;
  16. }, "Invalid email format: please use a comma to separate multiple email addresses.");