简体   繁体   中英

Client Side Validations on Heroku

I am using https://github.com/bcardarella/client_side_validations to validate my sign up form.

I am validating the uniqueness of username and email in that form:

validates_uniqueness_of :username, :email, :case_sensitive => false

The database validations for uniqueness are taking place fine on my local machine. But when I try them on Heroku, they do not work.

Edit:

Here is the sign up form (I am using devise):

<%= form_for @user, :as => :user, :validate => true, :url => user_registration_path do |f| %>
    <div><%= f.label :name, :class => "signupin-label span-2" %><%= f.text_field :name, :class => "signupin-field last", :autocomplete => "off"%></div>
    <div><%= f.label :username, :class => "signupin-label span-2" %><%= f.text_field :username, :class => "signupin-field last", :autocomplete => "off" %></div>
    <div><%= f.label :email, :class => "signupin-label span-2" %><%= f.text_field :email, :class => "signupin-field last", :autocomplete => "off" %></div>
    <div><%= f.label :password, :class => "signupin-label span-2" %><%= f.password_field :password, :class => "signupin-field last", :autocomplete => "off" %></div>
    <div class="signupin-bl"><%= f.submit "Sign up", :id => "signUpButton"  %></div>
<% end %>

I am getting following error:

rails.validations.js:154

Uncaught TypeError: Object (?-mix:^(a-zA-Z* ?| ([a-zA-Z0-9]+_?)*)$) has no method 'test'

Can someone please guide?

Thanks!

I found the issue. I was not validating the format of username on the client side and that was causing this error. Thanks for your help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM