You need to sign in to do that
Don't have an account?

Email validation in Apex Controller
HI Friends,
Can any one suggest me how to write Email Validation in apex controller. Here i am using one Regular expression to validate the Email in my controller method but its not working as per my senario
Using this Code in IF : if(Pattern.matches('[a-zA-Z0-9._-]+@[a-zA-Z-]+.[a-zA-Z.]{2,4}',cust_conemail)){
//
//
}
But its allows in all senarios but the thing is after @ need to accept only one or none hyphen but now its allowing more than one hyphens.
want this format : shiva.pendem@stead-fast.com //working fine
the issue is : shiva.pendem@stead--fast.com i want to restrict this format (More than one Hyphen). // need to restrict this
i.e only one or none hyphen want to allow.
please suggest me.
Thanks
shiva.
Can any one suggest me how to write Email Validation in apex controller. Here i am using one Regular expression to validate the Email in my controller method but its not working as per my senario
Using this Code in IF : if(Pattern.matches('[a-zA-Z0-9._-]+@[a-zA-Z-]+.[a-zA-Z.]{2,4}',cust_conemail)){
//
//
}
But its allows in all senarios but the thing is after @ need to accept only one or none hyphen but now its allowing more than one hyphens.
want this format : shiva.pendem@stead-fast.com //working fine
the issue is : shiva.pendem@stead--fast.com i want to restrict this format (More than one Hyphen). // need to restrict this
i.e only one or none hyphen want to allow.
please suggest me.
Thanks
shiva.
Use the following code, it will work.