Hi,
I am trying to validate the email format by using "validates_format_of".
I have written a code like this:-
"validates_format_of :email,
:with=>/^[0-9a-zA-Z_][\w\.-]*[a-zA-Z0-9_]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/,
:message => "is not valid" "
It is working fine, but in my application email id is not manadatory.
So how should add the condition in this validator so that it will
validate the email only when the email address is present.
Hi,
I am trying to validate the email format by using "validates_format_of".
I have written a code like this:-
"validates_format_of :email,
:with=>/^[0-9a-zA-Z_][\w\.-]*[a-zA-Z0-9_]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/,
:message => "is not valid" "
It is working fine, but in my application email id is not manadatory.
So how should add the condition in this validator so that it will
validate the email only when the email address is present.