Hi As an example
validates_format_of :phone_number,:allow_nil => true,:with => /regex here/
Sijo
Hi As an example
validates_format_of :phone_number,:allow_nil => true,:with => /regex here/
Sijo
i don't understand... could you please explain more
also , i thought i use the wrong word.
There are two field like this
Mobile Phone................ Phone .....................
validate if mobile phone Or phone is filled , not neccessary to field both, but filled at least one.
Hi
What I understood is you have to check presence of phone number and mobile number But not at the same time Right? If so please try the following Assuming you have the fields phone_number and mobile_number
validates_presence_of :mobile_number,:if => :phone_number_blank_check validates_presence_of :phone_number,:if => :mobile_number_blank_check
def phone_number_blank_check self.phone_number.blank? end
def mobile_number_blank_check self.mobile_number.blank? end
Sijo
Write your own validate routine instead of using the helpers.
Hi
i want it to appear only one message tell that phone number or mobile number can't be blank, how could i do that.
You can do like
def validate validate_phone_and_mobile([mobile_number,phone_number]) end
def validate_phone_and_mobile(numbers)
errors.add_to_base("phone number and/or mobile number can't be blank") if (numbers.first.blank? or numbers.second.blank?) or (numbers.first.blank? and numbers.second.blank?)
end
Sijo
Thriving K. wrote:
Mukund wrote:
Write your own validate routine instead of using the helpers.
On Sep 29, 11:32�am, "Thriving K." <rails-mailing-l...@andreas-s.net>
Is there any guideline for that... please.
www.google.com
I have something like this in one of my apps for email and cell:
validate :presence_of_email_or_cell
def presence_of_email_or_cell errors.add("Either an email address or cell phone number is required") if email.blank? and cell_number.blank? end