javascript - jquery validate input array and passing dynamic values -


i'm trying validate group of input arrays using jquery validator plugin. i'm having problems understanding how pass element validation.

my code far:

$('#edit-fixtures').validate({             rules: {                 "player_a[]": {                     required: true,                     uniquematch: function () {                         return $(this).next('.player').val();                     },                 },                 "player_b[]": {                     required: true,                     uniquematch: function () {                         $(this).closest('.player').val();                     },                 },             }         }); 

my input elements series of paired select boxes named player_a[] player_b[] there 40 pairs. each pair should unique , that's i'll validating.

i'm trying pass value of nearest player_b changed player_a , vice versa.

i have change method validate on each change:

$(".player").change(function () {              var check = $(this).valid();              console.log("validation:", check);          }); 

i'm still working on validation method cant seem parameters method correctly.

is there way of doing this?

uniquematch: [$item1, $item2, ....]  $.validator.addmethod('uniquematch', function(value, element, parametervalue) {     var item1value = $(parametervalue[0]).val();     //and on...     //based on values, return true or false;     //voila! } 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -