I'd like to run script for each field which id begins with "imie" and ends with numbers 1 to 10. Each field "imie" depends on field "nazwisko" with the same number at the end eg. "imie6" depends on "nazwisko6".
$(document).ready(function () { $('#nowikons_dodaj').validate({ rules: { imie1: { required: { depends: function (element) { return $("#nazwisko1").is(":filled"); } } } } }); });
Here's also html/php code for these fields:for ($i = 1; $i <= 10; $i++) { echo "<tr><td>".$i."</td>"; echo "<td><input type='text' name='nazwisko".$i."' id='nazwisko".$i."'></td>"; echo "<td><input type='text' name='imie".$i."' id='imie".$i."'></td>";}