> 
> In this case, it probably makes sense to have a separate field for 
> country code, and possibly one for area code.
> 
> (And the proper way to write a phone number with a country code is to 
> put a + before the country code.)
> 
>  Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> [email protected]

I was about to follow-up with just that. :)

Have two fields for phone numbers:

US --> Area Code --> Local Number (use regexp to parse out all non-digit 
chars)
International --> Country Code --> Local Number (same regexp as per 
above)

Now you have a very simple regexp that is removing all non-digit chars 
and producing number formats for those fields.  Based on the user input, 
you can now format the way the number appears on the page using what 
Marnen suggested with the + chars.

The nice thing is you've just handled the way phone numbers should work 
- they house numbers only.  If your visitor can't input their numbers 
into the correct fields, that's not your problem but theirs.  You've 
already worked at making sure you've handled user related input errors 
with your application.  You cannot handle whether or not a user is smart 
enough to type in the right box. :)

-- 
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.

Reply via email to