我正在尝试对具有相同名称的多个表单进行验证,但我失败了这是我的代码
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("input.email").each(function(){
$.validator.addMethod("email", function(value, element) {
return this.optional(element) || /^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/i.test(value);
}, "Please enter a valid email address.");
});
$("#signup").validate({
rules: {
email: "required email",
},
});
});
</script>
<form method="post" action="jqueryregthank.html" name="signup" id="signup">
<input type="text" name="email[]" id='email'/><br />
<input type="text" name="email[]" id='email'/><br />
<input type="text" name="email[]" id='email'/><br />
<input type="submit" value=" Sign-UP " name='SUBMIT' id="SUBMIT"/>
</form>
我希望有一个人可以帮助我