cool wrote:
> Guys,
>
> I have a text field and the name is phone
> I used to enter contact number.
> In the new form when i enter 10 digit number like "1234567890" it
> is displaying 1234567890
> I want to display like in US format automatically like "(123)
> 456-7890".
> I need to provide validation for that field also.
> Can u help me how can i do that.
> Very badly i need a help. i am struck with this issue......
validates_format_of :phone, :with => ((\(\d{3}\) ?)|(\d{3}[-
\.]))?\d{3}[- \.]\d{4}(\s(x\d+)?){0,1}$
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---