in my webapp i have the need to allow users to enter unlimited email addresses in a form i have this working nicely its allowing multiple input fields to be added and is validating them perfectly thanks to the below question i found
How to validate array of inputs using validate plugin jquery
i have read the question and made the changes to my code and can confirm in console that its validating each input field and not allowing the form to be submitted
my problem is it only shows the "please enter your email" for one of the input fields. for example if i had 2 fields and enter an email in the first when i submit the form the "please enter your email" for the second input shows under the first input field
what possible methods are there to make it show for all
this is my JS so far
var validator = $(".webapp_auth_login_validation").validate({
rules: {"email[]": "required"},
messages: {"email[]": "Please enter you email"}
});
$('.webapp_js_cu_email_new').click(function(){
$('.webapp_js_cu_email_container').append('<div class="col-md-4 form-group"><label>Additional Email: <span class="text-danger">*</span></label><a href="javascript:void(0);" class="webapp_js_cu_email_remove" title="Remove field"> Remove </a><input type="text" name="email[]" class="form-control required"></div>');
});
$('.webapp_js_cu_email_container').on('click', '.webapp_js_cu_email_remove', function(e){
e.preventDefault();
$(this).parent('div').remove();
});
this is the html on the page
<div class="row webapp_js_cu_email_container">
<div class="col-md-4 form-group">
<label>Email Address: <span class="text-danger">*</span></label> <a href="javascript:void(0);" class="webapp_js_cu_email_new" > Add </a>
<input type="text" name="email[]" class="form-control required">
</div>