diff options
author | Hakim Cassimally <hakim@mysociety.org> | 2014-11-13 18:13:19 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2014-11-14 18:23:37 +0000 |
commit | 7826ff359728e7033012d501c02763f26786ce28 (patch) | |
tree | cede64a4ac24d2e74d1705bb90fbfba3d8ccfca7 | |
parent | 62e37f1d8d57ee8eebf6e8ecc388aeef23493e5d (diff) |
Fix JS-disabled submission in Chrome/Firefox.
Fixes #932, which is caused by HTML5 validation firing for hidden
elements, by setting #mapForm to novalidate by default, and reverting
this in fixmystreet.js.
Note that the 'novalidate' attribute, which is honoured by the browsers'
HTML5 validation, isn't to be confused with the class (class="validate")
which is picked up by fixmystreet.js, and therefore not problematic for
the no-js case.
-rwxr-xr-x | templates/web/base/around/display_location.html | 2 | ||||
-rw-r--r-- | templates/web/seesomething/around/display_location.html | 2 | ||||
-rw-r--r-- | web/js/fixmystreet.js | 4 |
3 files changed, 6 insertions, 2 deletions
diff --git a/templates/web/base/around/display_location.html b/templates/web/base/around/display_location.html index 182c1249e..dbe7d9ffd 100755 --- a/templates/web/base/around/display_location.html +++ b/templates/web/base/around/display_location.html @@ -39,7 +39,7 @@ %] [% IF allow_creation %] -<form action="[% c.uri_for('/report/new') %]" method="post" name="mapForm" id="mapForm" enctype="multipart/form-data" class="validate"> +<form action="[% c.uri_for('/report/new') %]" method="post" name="mapForm" id="mapForm" enctype="multipart/form-data" class="validate" novalidate> [% IF c.req.params.map_override %] <input type="hidden" name="map_override" value="[% c.req.params.map_override | html %]"> [% END %] diff --git a/templates/web/seesomething/around/display_location.html b/templates/web/seesomething/around/display_location.html index e90d1aa0e..ea0a499f7 100644 --- a/templates/web/seesomething/around/display_location.html +++ b/templates/web/seesomething/around/display_location.html @@ -19,7 +19,7 @@ %] -<form action="[% c.uri_for('/report/new') %]" method="post" name="mapForm" id="mapForm" enctype="multipart/form-data" class="validate"> +<form action="[% c.uri_for('/report/new') %]" method="post" name="mapForm" id="mapForm" enctype="multipart/form-data" class="validate" novalidate> [% IF c.req.params.map_override %] <input type="hidden" name="map_override" value="[% c.req.params.map_override | html %]"> [% END %] diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js index 7d75c8b65..c8f1fe697 100644 --- a/web/js/fixmystreet.js +++ b/web/js/fixmystreet.js @@ -203,6 +203,10 @@ $(function(){ }); }); + // Map form doesn't work in some browsers with HTML5 validation and hidden form, so + // we disable validation by default, and add it in the JS case. + // For some reason, the removeAttr doesn't work if we place it at beginning. + $('#mapForm').removeAttr('novalidate'); }); })(jQuery); |