Hi stephenprater,
I don't follow what you mean. I would welcome a solution that can be confined to just the method I'm adding, if I can avoid using another element outside of the actual form elements I need, to do this validation, that would be GREAT!
Currently, I have it working with the following method. I would like to fine tune it if at all possible, and then hopefully others can just take it and use it too:
- jQuery.validator.addMethod("multiEmail", function(value, element) {
var emails = value.split(',');
var validEmails = 0;
for(var i=0; i<emails.length; i++){
$("#testEmail").val(emails[i].trim());
if (!($("#testEmail").val().length)) {
continue;
} else {
if(!($("#testEmail").validate({errorPlacement: function(error, element) { }}).element("#testEmail"))){
validEmails++;
}
}
}
return (validEmails == 0);
}, "The format for one or more emails is incorrect.");
# $(function() {
String.prototype.trim = function () {
return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};
# });
Currently, this method, other than being added as a rule for an element as normal, it also requires the form to have the hidden element:
- <input type="hidden" name="testEmail" id="testEmail" class="email" value="" />