Regex for lastname or firstname in rails -


i know question on asked, couldn't find fits in case , works rails. i'm looking simple regex words can contain:

  • letters(no digits)
  • white spaces
  • . (dot) or - (dash)

the following regex allows letters, white space, dot , dash:

/[a-z\s.-]/i 

your validation in model be:

validates_format_of :first_name, :with => /[a-z\s.-]/i 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -