Skip to content

Commit

Permalink
set maxlength attribute on inputs if present in validation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
struan committed Apr 9, 2019
1 parent 0e46602 commit 355f891
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions web/cobrands/fixmystreet/fixmystreet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
});
},
Expand Down

0 comments on commit 355f891

Please sign in to comment.