Changeset:
        a014f5654e12
        
https://sourceforge.net/p/mrbs/hg-code/ci/a014f5654e12c1cc45b7e1159758c11b919794f5
Author:
        Campbell Morrison <[email protected]>
Date:
        Sat Aug 27 11:30:49 2016 +0100
Log message:

Fixed bug causing form validation to fail when using datalist inputs

diffstat:

 web/js/general.js.php |  13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r bb0432ba6d64 -r a014f5654e12 web/js/general.js.php
--- a/web/js/general.js.php     Fri Aug 26 16:01:06 2016 +0100
+++ b/web/js/general.js.php     Sat Aug 27 11:30:49 2016 +0100
@@ -247,13 +247,22 @@
     // though the input has no id or name, then we need to clear the values 
from those inputs just
     // before the form is submitted.   Note that we can't do it on the submit 
event because by that time
     // the browser has cached the values.  So we do it when the Submit button 
is clicked - and this event
-    // is also triggered if Enter is entered into an input field.
+    // is also triggered if Enter is entered into an input field.   But
+    // of course we can't clear the value if the input field needs to be
+    // validated, otherwise the validation will fail.
     ?>
     $('form:has(input[list]) input[type="submit"]').click(function() {
       $(this).closest('form')
              .find('input:not([name])')
              .not('input[type="submit"]')
-             .val('');
+             .each(function() {
+                 if (!$(this).prop('required') &&
+                     (typeof($(this).attr('pattern')) == 'undefined'))
+                 {
+                   $(this).val('');
+                 }
+               });
+              
     });
     
   }

------------------------------------------------------------------------------
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to