1

I am using client side validations with simple form in a rails 3.2.7 app, with the following Gemfile and validations (snippets).

# Gemfile
gem 'simple_form'
gem 'client_side_validations' # Javascript/Ajax validations
gem 'client_side_validations-simple_form'

# user.rb
validates :name, presence: true, 
                 uniqueness: true,
                 format: { with: /^[\p{L}]{3,15}$/iu }

For whatever reason, the javascript doesn't appear to be evaluating the regex properly, because I am always getting the "format" message (it's in my I18n file). However, when I disable the client_side_validations and submit the form, the validation passes.

The reason I am using p{L} is because I need to support French characters.

Ideally, I'd like to force server side evaluation (through ajax, similar to how the uniqueness check works), but I haven't found a way to do so.

Any suggestions? This doesn't have to be perfect, if there is some work-around where I can get close to the desired functionality I would be happy (i.e. is there any way to override the validation and maybe do something like /[.]{3,15}/).

Much appreciated!

4

0 回答 0