Forum Discussion

JuanSolorio1's avatar
JuanSolorio1
Qrew Cadet
8 years ago

Email field accepting non-email values

Is there no way to ensure that an email address in entered in the correct format in an email field?

We have users accidentally creating records where they enter only the name portion of the email address but forget the domain.

Shouldn't a field of type "email" at least ensure that the values are entered in the correct format (containing the "@[domain]" portion)?
  • AlexWilkinson's avatar
    AlexWilkinson
    Qrew Assistant Captain
    Additional suggestions:

    1. To trap embedded spaces within an invalid entry:
     and not Contains(Trim([Contact Email]," "))

    2. To ensure that a "." comes after the "@":
    and Contains(Trim(Part([Contact Email], 2, "@" )),".")

    3. Instead of a boolean, create a text-formula field that explains the problem or is "" if no problem is found. Then display the text-formula on the form if it's not "". That way, if the user has erred, they get some feedback. Here's an example that captures the most common problems and displays one-step-at-a-time feedback:

    var bool outerSpace = Trim( [Registrant Email] ) <> [Registrant Email];
    var bool innerSpace = Contains( Trim( [Registrant Email] ), " " );
    var bool missingAt = not Contains( [Registrant Email], "@" );
    var bool missingSuffix = Trim( Part( [Registrant Email], 2, "." ) ) = "";
    var bool missingName = Trim( Part( [Registrant Email], 1, "@") ) = "";
    var bool missingCompany = Trim( Part( Part( [Registrant Email], 2, "@" ), 1, "." ) ) = "";
    var text warnMessage = If( 
          $outerSpace, "Has extra spaces at the beginning or end. Please remove them.",
          $innerSpace, "Has a space inside the email address.",
          $missingAt, "Missing @ symbol.",
          $missingSuffix, "Missing .com or other suffix.",
          $missingName, "Missing name-text before the @ symbol.",
          $missingCompany, "Missing company-name between @ and .com or other suffix.",
          "" );
    If( [Registrant Email] = "" or $warnMessage = "", "", "Invalid email: " & $warnMessage )
  • MCFNeil's avatar
    MCFNeil
    Qrew Captain
    You could use a form rule to validate, but yes this is frustrating
  • Hi Matthew,

    Thanks for your reply.  A form rule may work for records entered via the form, but not for records created either uploads or grid edit unfortunately.

    Additionally, there does not seem to be an option for validating email addresses even via a form rule, as the only options for comparison are:

    Is equal to...
    Is not equal to...
    <
    < or =
    >
    > or =

    I would think that there would be a "contains" option to test for the presence of "@" but that's not the case.
  • As Matthew suggested you can make a boolean field to validate the email and use that field in form rules. But you need to invent the formula code yourself. put the formal field on the form to be sure that the form rules "see" it.  Forms tend to not recalculate fields which are not on the form explicitly.  You can put them in a section and hide the section using form rules.  If i get a chance I will look for examples of my formuals which validate, or maybe others will post some.  Like exactly 1 @ and at least 1 dot.
    • MCFNeil's avatar
      MCFNeil
      Qrew Captain
      formula checkbox - [Contains @]

      If(Contains([Email], "@"), true, false)

      then use that checkbox in form rule.
    • QuickBaseCoachD's avatar
      QuickBaseCoachD
      Qrew Captain
      Trim([Contact email])<>"" and Contains([Contact email],"@") and Contains([Contact email],".")
    • JuanSolorio1's avatar
      JuanSolorio1
      Qrew Cadet
      Thank you both, this is very helpful. I guess at this point what remains is the core issue, which is that this approach would not work if users were creating or updating records via grid edit (unless this option is disabled) or uploads.