JSFiddle - React, Tailwind, and code Playground

by asif097

HTML

<script src="http://ajax.microsoft.com/ajax/jquery.validate/1.6/jquery.validate.min.js"></script>
<form id="form" method="post">
    <input type="text" name="emails" id="emails" class="emails"><br/>
    <input type="text" name="emails2" id="emails2" class="emails2">
</form>

CSS

input {
    float:left;
    display:block;
}

JavaScript

jQuery.validator.addMethod(
    "multiemails",

function (value, element) {
    if (this.optional(element)) // return true on optional element
    return true;
    var emails = value.split(/[;,]+/); // split element by , and ;
    valid = true;
    for (var i in emails) {
        value = emails[i];
        valid = valid && jQuery.validator.methods.email.call(this, $.trim(value), element);
    }
    return valid;
},

jQuery.validator.messages.multiemails);

$("#form").validate({
    rules: {
        emails: {
            required: true,
            multiemails: true
        }
    },
    messages: {
        emails: {
            required: "Please enter an email adress",
            multiemails: "Incorrect Email address"
        }
    }

});