Im using the client side validation gem. And have ran the all the instructions as stated to get validation working, but validation doesnot work on my form.
My form:
<%= form_with(model: profile, local: true, method: :patch, multipart: true, validate: true) do |form| %>
I have put validate: true
as stated on document.
Rather than put validation in my model:
validates :name, :email, presence: true, length: { maximum: 10 }, if: :can_validate?
def can_validate
true
end
The doc says you can force on the form which I have done instead:
And in my text field I have applied the validation:
<%= form.text_field :name, validate: { presence: true }, id: :profile_name, class:"input is-large" %>
But the validation does not work at all, no error message.
I created a repo to reproduce your issue myself:
https://github.com/wmavis/so_rails_client_side_validations
It looks like client_side_validations works for me if I use form_for but does not work for me if I use form_with:
A search for "client_side_validations form_with
" turned up this link:
https://github.com/DavyJonesLocker/client_side_validations/issues/696
It seems like the easiest solution for you is to use form_for. If you need to use form_with, it seems like the developer may be working on a solution or have one coded on another branch.
Let me know if it works or if you need more help.