Skip to content

Commit 550221a

Browse files
committed
Version 1.1.3 input field match fixes.
1 parent 3703a8d commit 550221a

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ http://plugins.jquery.com/jquery-maxsubmit/
9797

9898
## History
9999

100+
1.1.3 Fixed count of HTML5 input elements
100101
1.1.2 Updated metadata for plugins.jquery.com
101102
1.1.1 Fixed syntax error messaing with Chrome
102103
1.1.0 Issue #2 reported by @Bubbendorf Update to demo to demonstrate fixes.

index.php

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2-
<html>
1+
<!DOCTYPE html>
2+
<html lang="en">
33
<head>
4+
<meta charset="UTF-8">
45
<title>jquery-maxsubmit plugin demo</title>
56
<meta name="Generator" content="EditPlus">
67
<meta name="Author" content="Jason Judge">
@@ -44,6 +45,8 @@
4445
$input = array(
4546
'text1' => 'Text 1',
4647
'text2' => 'Text 2',
48+
'text3' => '',
49+
'text4' => '',
4750
'textarea1' => "A nice\nstory.",
4851
'checkbox1' => 'on',
4952
'checkbox2' => '',
@@ -126,12 +129,27 @@ function getFormSubmissionLimit($default = false)
126129

127130
<p>
128131
<input type="text" name="text1" value="<?php echo $input['text1']; ?>" />
129-
<span class="text_label" title="Click to toggle toggle the enabled state">(counts as one parameter)</span>
132+
<span class="text_label" title="Click to toggle toggle the enabled state">(text counts as one parameter)</span>
130133
</p>
131134

132135
<p>
133136
<input type="text" name="text2" value="<?php echo $input['text2']; ?>" />
134-
<span class="text_label" title="Click to toggle toggle the enabled state">(counts as one parameter)</span>
137+
<span class="text_label" title="Click to toggle toggle the enabled state">(text counts as one parameter)</span>
138+
</p>
139+
140+
<p>
141+
<input type="email" name="text3" value="<?php echo $input['text3']; ?>" />
142+
<span class="text_label" title="Click to toggle toggle the enabled state">(email counts as one parameter)</span>
143+
</p>
144+
145+
<p>
146+
<input type="date" name="text4" value="<?php echo $input['text4']; ?>" />
147+
<span class="text_label" title="Click to toggle toggle the enabled state">(date counts as one parameter)</span>
148+
</p>
149+
150+
<p>
151+
<input type="hidden" value="hidden" />[hidden]
152+
<span class="text_label" title="Click to toggle toggle the enabled state">(hidden field counts as one parameter)</span>
135153
</p>
136154

137155
<p>

jquery-maxsubmit.jquery.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"maxinputvars",
88
"suhosin"
99
],
10-
"version": "1.1.2",
10+
"version": "1.1.3",
1111
"author": {
1212
"name": "Jason Judge",
1313
"url": "https://github.com/judgej"

jquery.maxsubmit.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright 2013-2014 Academe Computing Ltd
33
* Released under the MIT license
44
* Author: Jason Judge <[email protected]>
5-
* Version: 1.1.2
5+
* Version: 1.1.3
66
*/
77
/**
88
* jquery.maxsubmit.js
@@ -61,8 +61,19 @@
6161
// We have a form, so count up the form items that will be
6262
// submitted to the server.
6363

64-
// Text fields and submit buttons will all post one parameter.
65-
var form_count = $('input:text:enabled, input:submit:enabled, input:password:enabled, textarea:enabled', this).length;
64+
// textarea fields count as one submitted field each.
65+
var form_count = $('textarea:enabled', this).length;
66+
67+
// Input fields of all types except checkboxes and radio buttons will
68+
// all post one parameter.
69+
// reset inputs are not submitted to the server and files are handled
70+
// separately.
71+
form_count += $('input:enabled', this)
72+
.not("[type='checkbox']")
73+
.not("[type='radio']")
74+
.not("[type='file']")
75+
.not("[type='reset']")
76+
.length;
6677

6778
// Checkboxes will post only if checked.
6879
$('input:checkbox:enabled', this).each(function() {
@@ -81,7 +92,8 @@
8192
if (select !== null) form_count += select.length;
8293
});
8394

84-
// Each radio button group will post one parameter.
95+
// Each radio button group will post one parameter, regardless of how many
96+
// radio buttons a group contains.
8597
// Count the radio groups
8698
var rgroups = [];
8799
$('input:enabled:radio').each(function(index, el) {

0 commit comments

Comments
 (0)