katie
katie

Reputation: 2951

Is it possible in Rails to validate input through javascript

I need to validate if input is equal to the some value in database through javascript(without refreshing the page),Is that possible and how do you do that in Rails 3? Thank you in advance.

Upvotes: 2

Views: 205

Answers (1)

hagope
hagope

Reputation: 5531

You'll want to take a look at client_side_validations gem. This integrates, rails, jQuery, server and client side validation: https://github.com/bcardarella/client_side_validations

Ryan Bates has a good screencast on this topic: http://railscasts.com/episodes/263-client-side-validations

got to about 4 minutes into the video, where he does an ajax request to validate the uniqueness of a username in the database.

and browse the source of his example http://github.com/railscasts/episode-263

Upvotes: 2

Related Questions