Now Im doing PHP code combine with JQuery. Im not experiance with Jquery. now i want to do real time validate insert multiple email. the insert is separate by comma (,).. here what im doing
$(function() {
$('.validateEmails').on('input', function() {
var emails = $(this).val();
emails = emails.replace(/^\s+|\s+$/g, "");
if (emails.match(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i)) {
console.log("email match");
} else {
console.log("email not match");
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<label >Emails: </label>
<input type="text" class="validateEmails" name="emails" size="50">
<Br>
<span> <small>*Please add (,) comma for send multiple email </small></span>
my code just only handle single email not multiple email. how do i still able to validate multiple email separate by comma(,).
Ex. "halo@email.com" -> this will return "email match"
but how if i input "halo@email.com, test@email.com". this still can return "email match"
please help