Why js adalat the contents of the second input email?

Check for correct email
$("input.email").change(function() { 
 var emailVal = $("input.email").val();
 var regex = new RegExp("^[-._a-z0-9]+@(?:[a-z0-9][-a-z0-9]+\.)+[a-z]{2,6}$");
if(regex.test(emailVal)){
$("input.email").removeClass('error');
 } else{
$("input.email").val(");
 $("input.email").addClass('error'); 
}
 });


Let's say I have two forms on the same page in both the first normally he checks and the second with the same class only removes.
Why?
July 9th 19 at 11:11
1 answer
July 9th 19 at 11:13
Solution
You need inside the handler not to handle "input.email", and to this.

Find more questions by tags JavaScriptjQuery