From f7870e94b12791c9a6082d970b38f45e411f31b5 Mon Sep 17 00:00:00 2001 From: mehrnaz-charkhchi Date: Thu, 16 Nov 2023 15:12:30 +0000 Subject: [PATCH 1/6] Add a class to register form name field. --- htdocs/components/00_jquery_validate.js | 7 ++++-- modules/EnsEMBL/Web/Form/Element/Name.pm | 28 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 modules/EnsEMBL/Web/Form/Element/Name.pm diff --git a/htdocs/components/00_jquery_validate.js b/htdocs/components/00_jquery_validate.js index b43966a13d..3de25078c7 100644 --- a/htdocs/components/00_jquery_validate.js +++ b/htdocs/components/00_jquery_validate.js @@ -123,11 +123,13 @@ $.extend($.validator, { validClass: 'valid', invalidClass: 'invalid', requiredClass: 'required', - trim: [ 'int', 'nonnegint', 'posint', 'float', 'nonnegfloat', 'posfloat', 'email', 'url' ], + trim: [ 'int', 'nonnegint', 'posint', 'float', 'nonnegfloat', 'posfloat', 'email', 'url','name','required' ], tests: { 'int': new RegExp(/^[\-+]?\d+$/), 'float': new RegExp(/^([\-+]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([\-+]?\d+))?$/), password: new RegExp(/^\S{6,32}$/), + required: new RegExp(/(.|\s)*\S(.|\s)*/), + name: new RegExp(/^[\x00-\x7F]*$/), email: new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i), url: new RegExp(/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i) }, @@ -147,7 +149,8 @@ $.extend($.validator, { posfloat: 'Please enter a number (minimum 1)', password: 'The password you have entered is invalid', email: 'Please enter a valid email address', - url: 'Please enter a valid URL' + url: 'Please enter a valid URL', + name: 'Please use english characters' } }, diff --git a/modules/EnsEMBL/Web/Form/Element/Name.pm b/modules/EnsEMBL/Web/Form/Element/Name.pm new file mode 100644 index 0000000000..d0c5235f00 --- /dev/null +++ b/modules/EnsEMBL/Web/Form/Element/Name.pm @@ -0,0 +1,28 @@ +=head1 LICENSE + +Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute +Copyright [2016-2022] EMBL-European Bioinformatics Institute + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +=cut + +package EnsEMBL::Web::Form::Element::Url; + +use strict; + +use base qw(EnsEMBL::Web::Form::Element::String); + +use constant { + VALIDATION_CLASS => '_name', +}; From 9ed3f99552eb93d2b8b7b0d67d8c75b5139f0a1b Mon Sep 17 00:00:00 2001 From: mehrnaz-charkhchi Date: Fri, 17 Nov 2023 11:14:37 +0000 Subject: [PATCH 2/6] Add name field type. --- modules/EnsEMBL/Web/Form/Element.pm | 1 + modules/EnsEMBL/Web/Form/Element/Name.pm | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/EnsEMBL/Web/Form/Element.pm b/modules/EnsEMBL/Web/Form/Element.pm index 0fb8d8e796..4f35a4661b 100644 --- a/modules/EnsEMBL/Web/Form/Element.pm +++ b/modules/EnsEMBL/Web/Form/Element.pm @@ -114,6 +114,7 @@ sub map_element_class { 'form-element-div' => 'EnsEMBL::Web::Form::Element::Div', 'form-element-dropdown' => 'EnsEMBL::Web::Form::Element::Dropdown', 'form-element-email' => 'EnsEMBL::Web::Form::Element::Email', + 'form-element-name' => 'EnsEMBL::Web::Form::Element::Name', 'form-element-file' => 'EnsEMBL::Web::Form::Element::File', 'form-element-filterable' => 'EnsEMBL::Web::Form::Element::Filterable', 'form-element-float' => 'EnsEMBL::Web::Form::Element::Float', diff --git a/modules/EnsEMBL/Web/Form/Element/Name.pm b/modules/EnsEMBL/Web/Form/Element/Name.pm index d0c5235f00..d78c58df04 100644 --- a/modules/EnsEMBL/Web/Form/Element/Name.pm +++ b/modules/EnsEMBL/Web/Form/Element/Name.pm @@ -17,7 +17,7 @@ limitations under the License. =cut -package EnsEMBL::Web::Form::Element::Url; +package EnsEMBL::Web::Form::Element::Name; use strict; @@ -26,3 +26,5 @@ use base qw(EnsEMBL::Web::Form::Element::String); use constant { VALIDATION_CLASS => '_name', }; + +1; From 18fec510721d1d8ca6dc314366d24577e3510ec3 Mon Sep 17 00:00:00 2001 From: mehrnaz-charkhchi Date: Fri, 17 Nov 2023 16:33:33 +0000 Subject: [PATCH 3/6] Update regex & error message. --- htdocs/components/00_jquery_validate.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/components/00_jquery_validate.js b/htdocs/components/00_jquery_validate.js index 3de25078c7..b2bfd27864 100644 --- a/htdocs/components/00_jquery_validate.js +++ b/htdocs/components/00_jquery_validate.js @@ -129,7 +129,7 @@ $.extend($.validator, { 'float': new RegExp(/^([\-+]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([\-+]?\d+))?$/), password: new RegExp(/^\S{6,32}$/), required: new RegExp(/(.|\s)*\S(.|\s)*/), - name: new RegExp(/^[\x00-\x7F]*$/), + name: new RegExp(/^[\x00-\x7F]+$/), email: new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i), url: new RegExp(/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i) }, @@ -150,7 +150,7 @@ $.extend($.validator, { password: 'The password you have entered is invalid', email: 'Please enter a valid email address', url: 'Please enter a valid URL', - name: 'Please use english characters' + name: 'Please write your name using only Latin characters' } }, From 9cfa59396041646f0325d3dee9be1b20be17c6bd Mon Sep 17 00:00:00 2001 From: Mehrnaz Charkhchi <7411372+Mehrnaz-Charkhchi@users.noreply.github.com> Date: Fri, 17 Nov 2023 17:08:28 +0000 Subject: [PATCH 4/6] Update 00_jquery_validate.js --- htdocs/components/00_jquery_validate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/components/00_jquery_validate.js b/htdocs/components/00_jquery_validate.js index b2bfd27864..00caa78f36 100644 --- a/htdocs/components/00_jquery_validate.js +++ b/htdocs/components/00_jquery_validate.js @@ -123,7 +123,7 @@ $.extend($.validator, { validClass: 'valid', invalidClass: 'invalid', requiredClass: 'required', - trim: [ 'int', 'nonnegint', 'posint', 'float', 'nonnegfloat', 'posfloat', 'email', 'url','name','required' ], + trim: [ 'int', 'nonnegint', 'posint', 'float', 'nonnegfloat', 'posfloat', 'email', 'url','name'], tests: { 'int': new RegExp(/^[\-+]?\d+$/), 'float': new RegExp(/^([\-+]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([\-+]?\d+))?$/), From 138bee6985948addb9ae125f482d20c045ba4925 Mon Sep 17 00:00:00 2001 From: mehrnaz-charkhchi Date: Fri, 17 Nov 2023 17:15:18 +0000 Subject: [PATCH 5/6] Revert required validation updates to the original. --- htdocs/components/00_jquery_validate.js | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/components/00_jquery_validate.js b/htdocs/components/00_jquery_validate.js index 00caa78f36..75440c1300 100644 --- a/htdocs/components/00_jquery_validate.js +++ b/htdocs/components/00_jquery_validate.js @@ -128,7 +128,6 @@ $.extend($.validator, { 'int': new RegExp(/^[\-+]?\d+$/), 'float': new RegExp(/^([\-+]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([\-+]?\d+))?$/), password: new RegExp(/^\S{6,32}$/), - required: new RegExp(/(.|\s)*\S(.|\s)*/), name: new RegExp(/^[\x00-\x7F]+$/), email: new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i), url: new RegExp(/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i) From 8c664982a9cc2e3d0f8f09c08818a8f8f71eda11 Mon Sep 17 00:00:00 2001 From: mehrnaz-charkhchi Date: Wed, 25 Sep 2024 12:11:58 +0000 Subject: [PATCH 6/6] Disable register button if a field is not valid. --- htdocs/components/30_forms.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/components/30_forms.css b/htdocs/components/30_forms.css index 4fa7807a29..f57c5afc54 100644 --- a/htdocs/components/30_forms.css +++ b/htdocs/components/30_forms.css @@ -453,3 +453,9 @@ form.freeform-stt label { font-weight:bold; } form.gallery-header label { font-size: 120%; width:40%!important; } form.gallery-header div.ff-right { padding-left: 40%; } +form#registration:has(input.invalid) input[type="button"] { + background-color: #999999; + cursor: default; + pointer-events: none; +} +