aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2019-04-08 15:38:44 +0100
committerStruan Donald <struan@exo.org.uk>2019-04-09 09:54:48 +0100
commit355f8917190c564d0ace2d0d05385441a119d735 (patch)
tree6fa552af93c3291695eb0bfe2e5c1d186101528e
parent0e46602ffb3fa6f1b86474449972bd7d5572af61 (diff)
set maxlength attribute on inputs if present in validation
If a field has a maximum length set in the javascript validation then add a maxlength attribute so the user doesn't have to wait till submission to find out about it.
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index 160c39e5f..bf7d5457f 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -446,6 +446,11 @@ $.extend(fixmystreet.set_up, {
var $el = $('#form_' + name);
if ($el.length) {
$el.rules('add', rule);
+ if (rule.maxlength) {
+ $el.attr('maxlength', rule.maxlength);
+ } else {
+ $el.removeAttr('maxlength');
+ }
}
});
},