Skip to content

Commit

Permalink
Add pattern validation to the email address field on the feedback page.
Browse files Browse the repository at this point in the history
Also add some other attributes to the field that are useful for such a
field (placeholder, autocorrect: off, and autocapitalization: off), and
make the field of type "email" instead of "text" to begin with.

It also wouldn't hurt to add server side validation of this fields
contents in case an email saved for the user in the database is not
valid, but that is not done yet here.
  • Loading branch information
drgrice1 committed Feb 14, 2024
1 parent 0ef28a2 commit c4ffa56
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions templates/ContentGenerator/Feedback.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,16 @@
<div class="row mb-3">
<%= label_for 'from', class => 'col-form-label col-auto', begin =%><b><%= maketext('From:') %></b><% end =%>
<div class="col-auto">
<%= text_field from => $user_email_address, class => 'form-control', size => 40, id => 'from',
$user_email_address ? (disabled => undef, readonly => undef) : (required => undef) =%>
<%= email_field from => $user_email_address, class => 'form-control', size => 40, id => 'from',
$user_email_address
? (disabled => undef, readonly => undef)
: (
required => undef,
placeholder => 'Email address',
autocorrect => 'off',
autocapitalize => 'off',
pattern => '^[a-zA-Z0-9.!#$%&\'*+\\/=?^_`~\\-]+@[a-zA-Z0-9\\-]+\\.[a-zA-Z0-9.\\-]+$'
) =%>
</div>
</div>
% if (stash 'send_error') {
Expand Down

0 comments on commit c4ffa56

Please sign in to comment.