Helpful Information
 
 
Category: Ruby Programming
Ruby form field masking

Hi,

I'm wondering if there is a way to apply a mask to a form field with Ruby. For example, a social security number or phone number format. None of my Ruby or Rails books mentions anything about it.

Thanks!
~Snow

Edit: I misunderstood.

No, it's best to do the checking rails-side and flash() if there's a problem, otherwise use javascript.

You can use some regular expressions for checking.

if ($ssn =~ /\d{7}/) then
puts "hooray" #their social security number is seven digits (i don't know the exact format, i can help you with the regexp if you give me that though)
end










privacy (GDPR)