diff options
-rw-r--r-- | web/cobrands/fixamingata/js.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/web/cobrands/fixamingata/js.js b/web/cobrands/fixamingata/js.js index ca5f772c4..5af23002a 100644 --- a/web/cobrands/fixamingata/js.js +++ b/web/cobrands/fixamingata/js.js @@ -1 +1,20 @@ fixmystreet.inspect_form_no_scroll_on_load = 1; + +// Chrome ignores autocomplete="off" on the title input, +// and incorrectly autocompletes it with the user's email address. +// For now we'll reset the title to empty if it contains +// an email address when the user has selected a category. +// Hopefully we can get rid of this eventually if Chrome changes +// its behaviour. +fixmystreet.fixChromeAutocomplete = function() { + let title = document.getElementById("form_title"); + + if (title) { + if (title.value == "" || + /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@(?:\S{1,63})$/.test(title.value)) { + title.value = ""; + } + } +} + +$(fixmystreet).on('report_new:category_change', fixmystreet.fixChromeAutocomplete); |