JSFiddle - React, Tailwind, and code Playground

by Brian Douglas

HTML

<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.js"></script>
<form>
    <input id='emailTest' name='emailTest' />
    <input type='submit' />
</form>

JavaScript

$.validator.addMethod(
    "multiemail",
    function (value, element) {
        if (this.optional(element))
            return true;
        var emails = value.split(/[;,]+/); // split element by , and ;
        valid = true;
        for (i = 0; i < emails.length; i++) {
            value = emails[i];
            valid = valid && $.validator.methods.email.call(this, $.trim(value), element);
        }
        return valid;
    },
    $.validator.messages.multiemail
);

$("form").validate({
    debug: true,
    rules: {
            emailTest: {
                multiemail: true
            }
        },
    messages: {
            emailTest: {
                multiemail: "You must enter a valid email, or comma separate multiple"
            }
        },
    submitHandler: function(form) {
            return false;
        }
});