aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2019-07-05 17:20:08 +0100
committerMatthew Somerville <matthew@mysociety.org>2019-07-19 12:10:17 +0100
commit38ad36ec4b9224581e8ecfad09aab183ef70ec0b (patch)
treeb55dfc8aa9902567f88e82c70de63da11f637ac1
parentde0c9769541ef889ccc3f9f3289e01538d3f071e (diff)
Include visually-hidden "Error" in all JS messages
-rw-r--r--templates/web/base/js/translation_strings.html1
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js7
2 files changed, 8 insertions, 0 deletions
diff --git a/templates/web/base/js/translation_strings.html b/templates/web/base/js/translation_strings.html
index 8968247d5..0210aff84 100644
--- a/templates/web/base/js/translation_strings.html
+++ b/templates/web/base/js/translation_strings.html
@@ -4,6 +4,7 @@ fixmystreet.password_minimum_length = [% c.cobrand.password_minimum_length %];
translation_strings = {
update: '[% loc('Please enter a message') | replace("'", "\\'") %]',
+ error: '[% loc('Error') | replace("'", "\\'") %]',
title: {
required: '[% loc('Please enter a subject') | replace("'", "\\'") %]',
maxlength: '[% loc('Summaries are limited to {0} characters in length. Please shorten your summary') | replace("'", "\\'") %]'
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index 60fbb723b..8a300085b 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -298,6 +298,13 @@ $.extend(fixmystreet.set_up, {
var submitted = false;
+ var defaultMessage = jQuery.validator.prototype.defaultMessage;
+ jQuery.validator.prototype.defaultMessage = function() {
+ var message = defaultMessage.apply(this, arguments);
+ message = '<span class="visuallyhidden">' + translation_strings.error + ':</span> ' + message;
+ return message;
+ };
+
$("form.validate").each(function(){
fixmystreet.validator = $(this).validate({
rules: validation_rules,