Hi I am new to rails and have the following rails form, which works fine.
<%= form_for :user, url: users_path do |f| %>
<p>
<%= f.text_field :email, :placeholder=>'first name' %>
<%= f.text_field :email, :placeholder=>'last name' %>
<%= f.email_field :email, :placeholder=>'email address' %>
<%= f.password_field :password, :placeholder=>'password' %>
<%= f.password_field :password2, :placeholder=>'password2' %>
</p>
<%= f.submit 'Sign up!', :class=>'btn-custom btn-submit' %>
<% end %>
On the email textbox there is some client side validation built into it which will not submit the form and highlight the field if it detects a string that isn't the format of an email address.
For some reason the built in form validation doesn't check whether the text fields are empty. Is there a rails way to make it check that?
I understand that I could do it with jquery and will do it that way if there is no other way but it seems silly to have 2 separate forms of validation code.
fyi I also have validation on my model.
use this:
<%= f.email_field :email, :required => true, :pattern => '[^@]+@[^@]+\.[a-zA-Z]{2,6}', :placeholder=>'email address' %>
Moreover:
you have these:
<%= f.text_field :email, :placeholder=>'first name' %>
<%= f.text_field :email, :placeholder=>'last name' %>
I guess it should be
<%= f.text_field :first_name, :placeholder=>'first name' %>
<%= f.text_field :last_name, :placeholder=>'last name' %>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다