You can always use the validate method
validate :must_be_phone_number
def must_be_phone_number
errros.add_to_base("Must be a valid phone number")
end
Of course you wont just add the error, you will write a routine to validate
the phone format ;)
2010/1/25 Colin Law <[email protected]>
> 2010/1/25 Srikanth Jeeva <[email protected]>:
> > Hi,
> >
> > I am using validates_numericality_of :phone_number
> >
> > for validation of phone number. The phone number must also accept "-".
> >
> > for Example, "044-42652144"
>
> You can't use validates_numericality_of for that as it is not a number.
>
> Colin
>
> >
> > Can any one please help how to do it,
> >
> > Thanks,
> > Srikanth J
> > http://srikanthjeeva.blogspot.com
> > --
> > 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]<rubyonrails-talk%[email protected]>
> .
> > For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
> >
> >
>
> --
> 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]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
Atenciosamente,
----------
Ênio Lopes
--
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.