From af6f3bc87ec14fd166a16336a2f0e4a77c6dc2b7 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Fri, 14 Aug 2015 14:22:28 +0300 Subject: [PATCH] Relax email inputs on client side #2855 --- .../javascripts/shared/jquery.validate.bootstrap.coffee | 3 +++ app/views/admin/admin_users/_form.haml | 2 +- app/views/admin/registrars/_form.haml | 6 +++--- app/views/registrar/contacts/form_partials/_general.haml | 8 ++++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/shared/jquery.validate.bootstrap.coffee b/app/assets/javascripts/shared/jquery.validate.bootstrap.coffee index 78960bb9a..698eb9706 100644 --- a/app/assets/javascripts/shared/jquery.validate.bootstrap.coffee +++ b/app/assets/javascripts/shared/jquery.validate.bootstrap.coffee @@ -18,3 +18,6 @@ $.validator.setDefaults error.insertAfter element return +jQuery.validator.addMethod 'lax_email', ((value, element) -> + @optional(element) or (value.match(new RegExp("@", "g")) || []).length == 1 +), 'Please enter a valid email address.' diff --git a/app/views/admin/admin_users/_form.haml b/app/views/admin/admin_users/_form.haml index 114a380d7..e7738a9f0 100644 --- a/app/views/admin/admin_users/_form.haml +++ b/app/views/admin/admin_users/_form.haml @@ -31,7 +31,7 @@ .col-md-4.control-label = f.label :email .col-md-8 - = f.text_field(:email, class: 'form-control', email: true) + = f.text_field(:email, class: 'form-control', lax_email: true) .form-group .col-md-4.control-label = f.label :country_code, t(:country) diff --git a/app/views/admin/registrars/_form.haml b/app/views/admin/registrars/_form.haml index 10698f338..f00bf6a14 100644 --- a/app/views/admin/registrars/_form.haml +++ b/app/views/admin/registrars/_form.haml @@ -31,12 +31,12 @@ .col-md-4.control-label = f.label :email .col-md-7 - = f.text_field(:email, class: 'form-control', email: true) + = f.text_field(:email, class: 'form-control', lax_email: true) .form-group .col-md-4.control-label = f.label :billing_email .col-md-7 - = f.text_field(:billing_email, class: 'form-control', email: true) + = f.text_field(:billing_email, class: 'form-control', lax_email: true) .row .col-md-8 @@ -68,7 +68,7 @@ .col-md-4.control-label = f.label :country_code, t(:country) .col-md-7 - = f.select(:country_code, + = f.select(:country_code, SortedCountry.all_options(f.object.country_code), {}, class: 'form-control') .row diff --git a/app/views/registrar/contacts/form_partials/_general.haml b/app/views/registrar/contacts/form_partials/_general.haml index 9ef12d8f1..c695d6ada 100644 --- a/app/views/registrar/contacts/form_partials/_general.haml +++ b/app/views/registrar/contacts/form_partials/_general.haml @@ -12,7 +12,7 @@ = " [#{f.object.ident_country_code}]" - else - country_selected = @contact.persisted? ? '' : (params[:depp_contact].try(:[], :ident_country_code) || 'EE') - = f.select(:ident_country_code, SortedCountry.all_options(country_selected), {}, + = f.select(:ident_country_code, SortedCountry.all_options(country_selected), {}, class: 'js-ident-country-code', required: true) .form-group @@ -25,7 +25,7 @@ = " [#{f.object.ident_type}]" - else - type_selected = @contact.persisted? ? '' : (params[:depp_contact].try(:[], :ident_type) || 'bic') - = f.select(:ident_type, Depp::Contact::SELECTION_TYPES, + = f.select(:ident_type, Depp::Contact::SELECTION_TYPES, { selected: type_selected }, class: 'js-ident-type', required: true) @@ -56,13 +56,13 @@ .col-md-3.control-label = f.label :email, t(:email) + '*' .col-md-7 - = f.text_field :email, class: 'form-control', required: true, email: true + = f.text_field :email, class: 'form-control', required: true, lax_email: true .form-group .col-md-3.control-label = f.label :phone, t(:phone) + '*' .col-md-7 - = f.text_field :phone, class: 'form-control', + = f.text_field :phone, class: 'form-control', placeholder: '+372.12323344', required: true