From 3cbf0e2656f26956519894c400a11f9e434f7a51 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Wed, 29 Aug 2018 17:17:58 +0200 Subject: [PATCH] Enforce input of type date, enhancing UX for browser compatible. Note: the submitted date format is iso8601 YYYY-MM-DD (as we expect), even if the displayed date by the browser depends of the user's browser locale. Theses browsers then safely ignore input placeholder. This is why we can't display the expected date format elsewhere in the interface: these users will see another format as the one we expect, and we don't want to mislead them. The date format is only displayed as a placeholder, for browser non-compatible with input of type date. --- app/views/checks/_form.html.erb | 9 ++++----- config/locales/en.yml | 2 -- config/locales/fr.yml | 2 -- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/views/checks/_form.html.erb b/app/views/checks/_form.html.erb index 138b09d..378dce9 100644 --- a/app/views/checks/_form.html.erb +++ b/app/views/checks/_form.html.erb @@ -20,14 +20,13 @@ <%= f.input :domain_expires_at, required: true, input_html: { - type: :string, + type: :date, value: check.domain_expires_at&.to_date, - # min: Date.yesterday, - # max: 10.years.from_now.end_of_year.to_date + min: Date.yesterday, + max: 10.years.from_now.end_of_year.to_date }, as: :string, - placeholder: t(".domain_expires_at_placeholder"), - hint: t(".domain_expires_at_hint") + placeholder: t(".domain_expires_at_placeholder") %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 423d7a3..58c4495 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -122,8 +122,6 @@ en: unsupported: | This top-level domain isn't currently automatically supported. You'll have to fill and maintain yourself the expiry date. - domain_expires_at_hint: | - Fill the expiry date in YYYY-MM-DD format. domain_expires_at_placeholder: YYYY-MM-DD. ssl: domain: Hostname diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 56befae..e48ca32 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -155,8 +155,6 @@ fr: unsupported: | Cette extension n'est pas supportée automatiquement actuellement. Vous devrez saisir et maintenir vous-même sa date d'expiration. - domain_expires_at_hint: | - Renseignez la date d'expiration au format AAAA-MM-JJ. domain_expires_at_placeholder: AAAA-MM-JJ ssl: domain: Nom d'hôte