| 368 | | } |
| | 371 | }, |
| | 372 | /** |
| | 373 | * Test for multiple field values and returns value for storage. |
| | 374 | * |
| | 375 | * @static |
| | 376 | * @param {Object} data The properties to be checked for multiple fields. |
| | 377 | * @returns {Object} data The properties to be saved. |
| | 378 | */ |
| | 379 | multipleFieldsValidator: function (data) { |
| | 380 | var result = true; |
| | 381 | var values; |
| | 382 | $.each(data, function (el, i) { |
| | 383 | var arrChkBox = document.getElementsByName(el); |
| | 384 | var elementType = $(arrChkBox).get(0).tagName; |
| | 385 | |
| | 386 | switch (elementType) { |
| | 387 | case 'INPUT': |
| | 388 | if ($(arrChkBox).attr('type') == 'checkbox' && $(arrChkBox).size() > 1) |
| | 389 | result = false; |
| | 390 | values = $(arrChkBox).map(function () { |
| | 391 | if ($(this).is(':checked')) |
| | 392 | return $(this).val(); |
| | 393 | }).get(); |
| | 394 | break; |
| | 395 | case 'SELECT': |
| | 396 | if ($(arrChkBox).attr('multiple')) { |
| | 397 | result = false; |
| | 398 | values = $(arrChkBox).find('option').map(function () { |
| | 399 | if ($(this).is(':selected')) |
| | 400 | return $(this).val(); |
| | 401 | }).get(); |
| | 402 | } |
| | 403 | break; |
| | 404 | } |
| | 405 | if (!result) { |
| | 406 | data[el] = values; |
| | 407 | } |
| | 408 | }); |
| | 409 | return data; |
| | 410 | } |