Skip to content

Commit

Permalink
Add help on regexp field for phone number format
Browse files Browse the repository at this point in the history
  • Loading branch information
entantoencuanto committed Apr 18, 2024
1 parent bc9e8d6 commit 634f98c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= form.check_box :phone_number, label: t(".label"), help_text: t(".description"), data: { toggle: "phone_fields" } %>
</div>
<div class="row column pl-4" id="phone_fields" <%= "hidden" unless form.object.phone_number %>>
<%= form.text_field :phone_number_pattern, label: t(".pattern"), placeholder: "^(\\+34)?[0-9 ]{9,12}$" %>
<%= form.text_field :phone_number_pattern, help_text: t(".pattern_help_html"), label: t(".pattern"), placeholder: "^(\\+34|0034|34)?[ -]*[6-9][ -]*([0-9][ -]*){8}$", data: { type: :phone_number } %>
<%= form.text_field :phone_number_placeholder, label: t(".placeholder"), placeholder: "+34987654321" %>
</div>
</div>
3 changes: 2 additions & 1 deletion config/locales/ca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ ca:
phone_number:
description: Aquest camp és un camp telefònic. Si está activat, l'usuari haurà d'introduir un número de telèfon.
label: Habilitar camp de número de telèfon
pattern: Patró de validació de números de telèfon (regex)
pattern: Patró de validació de números de telèfon (regexp)
pattern_help_html: 'Copia aquesta expressió regular <code class="label">^(\+34|0034|34)?[ -]*[6-9][ -]*([0-9][ -]*){8}$</code> per validar aquest format de telèfono +34999111222'
placeholder: Placeholder pel número de telèfon
postal_code:
description: Aquest camp és un camp de text. Si está activat, l'usuari haurà d'introduir un codi postal.
Expand Down
5 changes: 4 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ en:
description: This field is a telephone field. If checked, user will
have to fill in a phone number
label: Enable phone number field
pattern: Phone numbers validation pattern (regex)
pattern: Phone numbers validation pattern (regexp)
pattern_help_html: Copy this regular expression <code class="label">^(\+34|0034|34)?[
-]*[6-9][ -]*([0-9][ -]*){8}$</code> to validate this phone format
+34999111222
placeholder: Phone number placeholder
postal_code:
description: This field is a String field. If checked, user will have
Expand Down
3 changes: 2 additions & 1 deletion config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ es:
phone_number:
description: Este campo es un campo telefónico. Si está marcado, el usuario deberá ingresar un número de teléfono.
label: Habilitar campo de número de teléfono
pattern: Patrón de validación de números de teléfono (regex)
pattern: Patrón de validación de números de teléfono (regexp)
pattern_help_html: 'Copia esta expresión regular <code class="label">^(\+34|0034|34)?[ -]*[6-9][ -]*([0-9][ -]*){8}$</code> para validar este formato de teléfono +34999111222'
placeholder: Placeholder para el número de teléfono
postal_code:
description: este campo es un campo de texto. Si está marcado, el usuario deberá ingresar un código postal.
Expand Down
1 change: 1 addition & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ fr:
pourra choisir un numéro.
label: Activer le champ numéro de téléphone
pattern: Motif de validation des numéros de téléphone (regex)
pattern_help_html: 'Copiez cette expression régulière <code class="label">^(\+34|0034|34)?[ -]*[6-9][ -]*([0-9][ -]*){8}$</code> pour valider ce format de téléphone +34999111222'
placeholder: Placeholder pour le numéro de téléphone
postal_code:
description: Ce champ est un champ code postal. L'utilisateur pourra
Expand Down

0 comments on commit 634f98c

Please sign in to comment.