how to validate .com in email

hi friends,

                emailaddressvaliate() is validating only @ symbol.how to validate .com domain in outystems

Hi Karthik,

What do you want to evaluate? if the email has the ".com" or if the email exists?


Regards,

António Pereira

You can use regex. And search some regex email validations on the internet.

Also, the email validate functions validates a lot more than the @. But acording to the email addresses spec the .com is not a mandatory part (even though it is not recommended to use email like those outside intranets) so it accepts that to comply with the specification.


Theres more topics regarding this, but like Niels said if you want different validation rules you should create your own validation function using regexs. Careful that many regex that you find online many not be complete enough or be too slow due to their complexity.


Regards,

João Rosado

Niels Favreau wrote:

You can use regex. And search some regex email validations on the internet.


Thanks Niels,

I use Regex email validations and it works

Regards,

Nhorwin

Hi John,

how did you use Regex for email validations can you share screenshots or sample code.

Thanks

Nhorwin John Villano wrote:

Niels Favreau wrote:

You can use regex. And search some regex email validations on the internet.


Thanks Niels,

I use Regex email validations and it works

Regards,

Nhorwin


Hi John,

how did you use Regex for email validations can you share screenshots or sample code.

Thanks



You would need to adapt the regex for your needs, but I used this for my example (but it allows any extension):

https://stackoverflow.com/questions/46155/how-to-validate-an-email-address-in-javascript


Then you'll create an action like this:

The JavaScript part will have an input (the email) and an output (the result - valid).


You should get results like this:

For more info on using JavaScript in your application, you can check out this module.

https://www.outsystems.com/learn/courses/44/master-class-on-javascript-and-jquery/?LearningPathId=2

For the people that want to have the regex to match email addresses. there are several available; I use the simple version as this is good enough for my use-case. If you have more rigorous requirements you could use the rfc 5322 compliant version. This one more resource intensive though.

Simple version:

\b[A-Z0-9][A-Z0-9._%+-]*@(?:[A-Z0-9-]+\.)+[A-Z]{2,}\b


RFC 5322 compliant:

\A[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*
@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\z