Validate email and password
This commit is contained in:
parent
069d565ba9
commit
4faa4fd555
3 changed files with 41 additions and 6 deletions
|
|
@ -1,13 +1,32 @@
|
|||
<h1><%= _("Create account") %></h1>
|
||||
|
||||
<% if @errors %>
|
||||
<% @errors.each do |error| %>
|
||||
<% if error.attribute == :password and error.type == :blank %>
|
||||
<p class="error"><%= _("Specify a password.") %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @user and @user.errors.any? %>
|
||||
<% @user.errors.each do |error| %>
|
||||
<% if error.attribute == :email and error.type == :invalid %>
|
||||
<p class="error"><%= _("Email is not a valid email address.") %></p>
|
||||
<% end %>
|
||||
<% if error.attribute == :email and error.type == :taken %>
|
||||
<p class="error"><%= _("An account already exists for %{email}.") % { email: @user.email } %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<form action="/signup" method="post">
|
||||
<p>
|
||||
<label for="email"><%= _("Email") %></label>
|
||||
<input type="text" name="email">
|
||||
<input type="text" name="email" value="<%= params[:email] %>">
|
||||
</p>
|
||||
<p>
|
||||
<label for="password"><%= _("Password") %></label>
|
||||
<input type="password" name="password">
|
||||
<input type="password" name="password" value="<%= params[:password] %>">
|
||||
</p>
|
||||
<button type="submit"><%= _("Create account") %></button>
|
||||
</form>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue