Skip to main content
Inspiring
May 14, 2007
Question

cfform and regex question

  • May 14, 2007
  • 3 replies
  • 466 views
I'm trying to make sure that a email address is in the correct format, using
this regex:

<cfinput type="text" name="contactEmail" id="contactEmail"
validate="regular_expression"
pattern="^([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.
(([a-z]{2,3})|(aero|coop|info|museum|name)))?$" message="Email is not in
correct format.">

When the form is submitted, it still processes a incorrectly formed email
address without a complaint.....


    This topic has been closed for replies.

    3 replies

    Inspiring
    May 14, 2007
    > <cfinput type="text" name="contactEmail" id="contactEmail"
    > validate="regular_expression"
    > pattern="^([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.
    > (([a-z]{2,3})|(aero|coop|info|museum|name)))?$" message="Email is not in
    > correct format.">
    >
    > When the form is submitted, it still processes a incorrectly formed email
    > address without a complaint.....

    What examples of incorrectly-formed email addresses is it accepting? I can
    think of a number of perfectly valid patterns that one will reject, too.

    To be frank, attempting to validate an internet email address (as per RFC
    2822) is a fool's errand. You could possibly validate the domain name
    part, but the local part can pretty much be anything one likes, anyhow. So
    on the LHS of the @ symbol, there's no pattern to validate.

    And what about this sort of thing:

    looks.ok@NotAValid.domain.foo

    Are you going to check that the domain is actually registered and active,
    and has an SMTP server receiving email? No, didn't think so. So what's
    the point?

    I can understand forcing a person to enter SOMETHING as an email address,
    and maybe type it in twice so as to minimise the chance of typos, but if
    they don't want to give you an email address, they won't.

    If you want to force a person to enter a VALID email address, then make
    sure part of their registration is done via responding to an email to their
    designated address...

    --
    Adam
    Inspiring
    May 14, 2007
    This is for CF MX 6.1.....

    "MichaelSJudd" <mikejudd@ratingsource.com> wrote in message
    news:f2abpi$o1i$1@forums.macromedia.com...
    > If you are using MX 7, a new attribute called "mask" has been added.
    >
    > - Mike


    Inspiring
    May 14, 2007
    If you are using MX 7, a new attribute called "mask" has been added.

    - Mike