Skip to content

Commit 14d4ea4

Browse files
author
tom bertrand
committed
Allow formData to be built as Array instead of Object only using "inputname[]"
1 parent 89a5994 commit 14d4ea4

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

dist/jquery.validation.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Licensed under the MIT license
55
*
66
* @author Tom Bertrand
7-
* @version 1.5.3 (2015-07-02)
7+
* @version 1.5.3 (2015-07-08)
88
* @link http://www.runningcoder.org/jqueryvalidation/
99
*/
1010
;
@@ -366,7 +366,6 @@
366366

367367
formData = {};
368368

369-
370369
$.each(
371370
node.find('input:not([type="submit"]), select, textarea').not(':disabled'),
372371
function(index, input) {
@@ -377,7 +376,15 @@
377376
inputName = input.attr('name');
378377

379378
if (inputName) {
380-
formData[inputName] = value;
379+
if (/\[]$/.test(inputName)) {
380+
inputName = inputName.replace(/\[]$/, '');
381+
if (!(formData[inputName] instanceof Array)) {
382+
formData[inputName] = [];
383+
}
384+
formData[inputName].push(value)
385+
} else {
386+
formData[inputName] = value;
387+
}
381388
}
382389

383390
if (!!input.attr(_data.validation) || !!input.attr(_data.regex)) {

0 commit comments

Comments
 (0)