Reputation: 781
does someone know how to add Umlauts to a regular expression to validate the format for a text input with rails?
I tried this but it breaks rails completely:
validates :first_name, :presence => true, :allow_blank => false, :format => { :with => /\A[a-z A-ZäöüÄÖÜ]+\z/}
Upvotes: 0
Views: 1072
Reputation: 8034
Try this:
validates :first_name, :presence => true, :allow_blank => false, :format => { :with => /\A[[:alpha:]]+\z/}
Upvotes: 3
Reputation: 8884
This should work, but make sure ruby itself knows what encoding you use in code by adding as the first line (assuming utf-8):
# encoding: UTF-8
let me know if it helps
Upvotes: 1