From 14fba482a8b38b3c93a13bb63db406701bbc06ad Mon Sep 17 00:00:00 2001 From: Jason Judge Date: Mon, 27 Jan 2014 00:30:54 +0000 Subject: [PATCH] Fixes for ticket #1 --- index.php | 44 ++++++++++++++++++++++++++++++++---- jquery-maxsubmit.jquery.json | 2 +- jquery.maxsubmit.js | 15 ++++++------ 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/index.php b/index.php index d04c261..8f3eb5b 100644 --- a/index.php +++ b/index.php @@ -9,6 +9,8 @@ + + + + + + + 'Text 1', 'text2' => 'Text 2', + 'textarea1' => "A nice\nstory.", 'checkbox1' => 'on', 'checkbox2' => '', ); foreach($input as $key => $value) { - $input[$key] = (isset($_POST[$key]) ? $_POST[$key] : '' ); + $input[$key] = (isset($_POST[$key]) ? htmlspecialchars($_POST[$key]) : $input[$key] ); } $input = array_merge( @@ -88,7 +108,7 @@ function getFormSubmissionLimit($default = false)

Thank you for posting some stuff! - On a real application you may have lost some data by doing so. + On a real application you may have lost some data by ignoring the warning.

@@ -97,35 +117,48 @@ function getFormSubmissionLimit($default = false) For these tests, we will set the limit to 2, so the confirm message is always shown.

+

+ Clicking the labels of the form items like this will disable those items, so they are not submitted. +

+

Mandatory form items: will count as one submitted parameter each

+ (counts as one parameter)

+ (counts as one parameter) +

+ +

+ + (counts as one parameter)

+ (counts as one parameter)

- Radio 1 + Radio 1

- Radio 2 + Radio 2


@@ -145,7 +178,8 @@ function getFormSubmissionLimit($default = false) $value) { ?> - (counts as up to three parameters) + + (counts as up to three parameters)

diff --git a/jquery-maxsubmit.jquery.json b/jquery-maxsubmit.jquery.json index 087131b..67d8508 100644 --- a/jquery-maxsubmit.jquery.json +++ b/jquery-maxsubmit.jquery.json @@ -7,7 +7,7 @@ "maxinputvars", "suhosin" ], -"version": "1.0.2", +"version": "1.1.0", "author": { "name": "Jason Judge", "url": "https://github.com/judgej" diff --git a/jquery.maxsubmit.js b/jquery.maxsubmit.js index 5478ace..5d9533c 100644 --- a/jquery.maxsubmit.js +++ b/jquery.maxsubmit.js @@ -2,7 +2,7 @@ * Copyright 2013-2014 Academe Computing Ltd * Released under the MIT license * Author: Jason Judge - * Version: 1.0.2 + * Version: 1.1.0 */ /** * jquery.maxsubmit.js @@ -34,7 +34,8 @@ // Can use {max_count} as a placeholder for the permitted maximum // and {form_count} for the counted form items. - max_exceeded_message: 'This form has too many fields for the server to accept.\n' + max_exceeded_message: + 'This form has too many fields for the server to accept.\n' + ' Data may be lost if you submit. Are you sure you want to go ahead?', // The function that will display the confirm message. @@ -60,20 +61,20 @@ // submitted to the server. // Text fields and submit buttons will all post one parameter. - var form_count = $('input:text, input:submit, input:password, textarea', this).length; + var form_count = $('input:text:enabled, input:submit:enabled, input:password:enabled, textarea:enabled', this).length; // Checkboxes will post only if checked. - $('input:checkbox', this).each(function() { + $('input:checkbox:enabled', this).each(function() { if (this.checked) form_count++; }); // Single-select lists will always post one value. - $('select:not([multiple])', this).each(function() { + $('select:enabled:not([multiple])', this).each(function() { form_count++; }); // Multi-select lists will post one parameter for each selected item. - $('select[multiple]', this).each(function() { + $('select:enabled[multiple]', this).each(function() { // The select item value is null if no options are selected. var select = $(this).val(); if (select !== null) form_count += select.length; @@ -82,7 +83,7 @@ // Each radio button group will post one parameter. // Count the radio groups var rgroups = []; - $('input:radio').each(function(index, el) { + $('input:enabled:radio').each(function(index, el) { var i; for(i = 0; i < rgroups.length; i++) { if (rgroups[i] == $(el).attr('name')) return;