Jump to content

How can create script for Is Valid Email ( the mail )


This topic is 1307 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi all,

I would like to create a script or function for the Email field in case the entry of the email without @ give him an error or an invalid address.


thanks a lot for any help or support :) 

Link to comment
Share on other sites

You could do a trigger OnObjectSave. The script would use this custom function https://www.briandunning.com/cf/360 and show a dialog. You could just use this part of the CF: 

Left ( yourEmailField ; Position ( yourEmailField ; "@" ; 1; 1 ) - 1 ) ;

Or, you could really go for it and use SendGrid's API to validate the email is real. https://sendgrid.com/docs/api-reference/ Email Address Validation.

Link to comment
Share on other sites

I suggest you start with something simple: validate the email field using a calculation =

PatternCount ( Self ; "@" )

This will produce a validation error when you try to commit a record where the email field does not contain the @ character.

Now, this simple solution has several flaws:

  1. It fires on record commit, not when user exits the field;
  2. The error message can be cryptic and confusing to the user;
  3. There are many other ways in which an email address can be invalid.

To solve the first two problems, you can attach an OnObjectValidate script trigger to the field and have it run a script along the lines of:

If [ not PatternCount ( YourTable::Email ; "@" ) ]
  Show Custom Dialog [ "The email is not valid." ]
  Exit Script [ Result: False ] 
End If

Script triggers work only on layouts where they have been installed. If you want to ensure data integrity, use the script trigger in addition to field validation, not instead of it.

The third problem is much more complicated and I won't go into it now.


Edited by comment
Link to comment
Share on other sites

This topic is 1307 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.