diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-09-22 10:02:08 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-09-22 10:02:08 +0100 |
commit | fb0a1dab4b22cb43b90a944b403632ca784e72b2 (patch) | |
tree | ac4bc77546461b914858bac5b1edcbf0358dbedc | |
parent | 148d702917f54327f82e49fe605e5a0d9f2e31ca (diff) | |
parent | d1e0cbd2a5efcaf3bdac8fb7ef09dca8c53417da (diff) |
Merge branch '1526-update-update-name-name'
-rw-r--r-- | templates/web/base/report/update/form_name.html | 2 | ||||
-rw-r--r-- | web/cobrands/fixmystreet-uk-councils/js.js | 9 | ||||
-rw-r--r-- | web/cobrands/fixmystreet.com/js.js | 11 |
3 files changed, 17 insertions, 5 deletions
diff --git a/templates/web/base/report/update/form_name.html b/templates/web/base/report/update/form_name.html index 19c31998e..33887117a 100644 --- a/templates/web/base/report/update/form_name.html +++ b/templates/web/base/report/update/form_name.html @@ -25,7 +25,7 @@ <p class='form-error'>[% field_errors.name %]</p> [% END %] -<input type="text" class="form-control validName js-form-name" +<input type="text" class="form-control validNameU js-form-name" name="name" id="form_name" value="[% update.name || c.user.name | html %]" placeholder="[% loc('Your name') %]"> <div class="checkbox-group"> diff --git a/web/cobrands/fixmystreet-uk-councils/js.js b/web/cobrands/fixmystreet-uk-councils/js.js index 3abba8e33..6066db9c5 100644 --- a/web/cobrands/fixmystreet-uk-councils/js.js +++ b/web/cobrands/fixmystreet-uk-councils/js.js @@ -1,3 +1,8 @@ -jQuery.validator.addMethod('validName', function(value, element) { +(function(){ var validNamePat = /\ba\s*n+on+((y|o)mo?u?s)?(ly)?\b/i; - return this.optional(element) || value.length > 5 && value.match( /\S/ ) && value.match( /\s/ ) && !value.match( validNamePat ); }, translation_strings.category ); + function valid_name(value, element) { + return this.optional(element) || value.length > 5 && value.match( /\S/ ) && value.match( /\s/ ) && !value.match( validNamePat ); + } + jQuery.validator.addMethod('validName', valid_name, translation_strings.name.required); + jQuery.validator.addMethod('validNameU', valid_name, translation_strings.name.required); +})(); diff --git a/web/cobrands/fixmystreet.com/js.js b/web/cobrands/fixmystreet.com/js.js index 68651e120..b38df87ed 100644 --- a/web/cobrands/fixmystreet.com/js.js +++ b/web/cobrands/fixmystreet.com/js.js @@ -1,6 +1,13 @@ -jQuery.validator.addMethod('validName', function(value, element) { +(function(){ var validNamePat = /\ba\s*n+on+((y|o)mo?u?s)?(ly)?\b/i; - return this.optional(element) || value.length > 5 && value.match( /\S/ ) && value.match( /\s/ ) && !value.match( validNamePat ); }, translation_strings.category ); + function valid_name_factory(single) { + return function(value, element) { + return this.optional(element) || value.length > 5 && value.match(/\S/) && (value.match(/\s/) || (single && !value.match('.@.'))) && !value.match(validNamePat); + }; + } + jQuery.validator.addMethod('validName', valid_name_factory(0), translation_strings.name.required); + jQuery.validator.addMethod('validNameU', valid_name_factory(1), translation_strings.name.required); +})(); $(function(){ |