I have many form create in for
I have this HTML
<form method="post" id="form_commento-[i]" class="form_fancybox_commenti">
<div class="form-section">
<span style="position: relative">
<input type="text" id="commento_form_[i]_commento" name="commento_form_[i][commento]" required="required"/>
<button type="submit" class="submit-button" id="submit_form_commenti">Commenta</button>
</span>
</div>
</form>
Where [i] is index
in my document ready I have
$(document).ready(function() {
jQuery.validator.addMethod("alphanumeric", function (value, element) {
return this.optional(element) || /^[a-zA-Z0-9\n\-'àèìòù: <_,. !?()]*$/.test(value);
}, "error");
$('.form_fancybox_commenti').each(function(index, numero_form) {
var theRules = {};
theRules[
'commento_form_['+index+'][commento]'] = {alphanumeric: true};
$(this).validate({
rules: theRules,
submitHandler: function(form) {
save(form);
}
});
});
but my custom rules doesn't works.
Anyway to resolve this problem?