regex test failing in form validation

Discussion in 'Javascript' started by lancemiller777, May 31, 2009.

  1. 1) http://lance-miller.appspot.com/?page=webform
    2) see the webform.js link at top of that page.
    3) turn on debug ( an onclick box upper right )
    4) enter URL's into HOMEPAGE field. e.g. http://example.com
    5) If you have debug on you'll see a decent report of what the code is
    doing.

    Problem: The regex for matching correct protocol and TLD for the URL
    is apparently doing the wrong thing, and I've been stuck for days.
     
    lancemiller777, May 31, 2009
    #1
    1. Advertisements

  2. lancemiller777

    Eric Bednarz Guest

    lancemiller777 <> writes:

    > 1) http://lance-miller.appspot.com/?page=webform
    > 2) see the webform.js link at top of that page.
    > 3) turn on debug ( an onclick box upper right )


    That’s hardly going to help much.

    > Problem: The regex for matching correct protocol and TLD for the URL
    > is apparently doing the wrong thing,


    You have a variable TLDlist that is
    a) offensive to the rest of the word
    b) a string literal that you want to use in the regexp

    To do the latter, you need to use the RegExp constructor, not a regular
    expression literal.

    (as is, using ‘TLDlist’ as TLD value works as designed :)

    > and I've been stuck for days.


    Using a real debugger would probably have saved some days. E.g., your
    debugging info just concatenates some strings and says ‘this is the
    regexp’, while that is not true at all.
     
    Eric Bednarz, May 31, 2009
    #2
    1. Advertisements

  3. Conrad Lender wrote:
    > On 01/06/09 00:02, Conrad Lender wrote:
    >> validating e-mail addresses (per RFC822, I think, or the updated
    >> version) is HARD.

    >
    > Hehe, just for kicks I'm pasting the regex from Perl's Email::Valid
    > module here. This is without a doubt one of my favorite pieces of code
    > ever... [...]


    It has been posted numerous times, and it is still both overkill and
    obsolete. Search the archives.


    PointedEars
     
    Thomas 'PointedEars' Lahn, May 31, 2009
    #3
  4. In comp.lang.javascript message <b6WdnQOXF7MVY7_XnZ2dnUVZ_sqdnZ2d@supern
    ews.com>, Mon, 1 Jun 2009 00:02:42, Conrad Lender <>
    posted:

    >But to be honest, accurately validating e-mail addresses (per RFC822, I
    >think, or the updated version) is HARD.


    As a pedagogic exercise, it is good. Correctly asked, it distinguishes
    the intelligent from the mere coding experts.

    It is discussed in <URL:http://www.merlyn.demon.co.uk/js-valid.htm>.

    This mail system, Turnpike, checks outgoing addresses fairly well,
    apparently; but I have no idea what methods it uses.

    In practice, as we have discussed before, one can easily enough validate
    to eliminate some classes of typing error - such as entering a phone
    number there.

    As there is no possibility of determining in advance whether an address
    is deliverable (reply0923@merlyn... is deliverable;
    reply0953@merlyn... may become deliverable; reply1053@merlyn... should
    not become deliverable; reply9952@merlyn... is not expected to become
    deliverable), there is no real benefit in checking the RFC compliance
    rigorously.

    One must allow for formats which become possible in future, either by
    not being too strict or by updating code.

    Your RegExp posting breaches FAQ 12, but not FAQ 9.91; that is a FAQ
    error.

    --
    (c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
    Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
    Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
    Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
     
    Dr J R Stockton, Jun 1, 2009
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott David Daniels

    Failing unittest Test cases

    Scott David Daniels, Jan 9, 2006, in forum: Python
    Replies:
    18
    Views:
    580
    Scott David Daniels
    Jan 13, 2006
  2. Replies:
    3
    Views:
    954
    Reedick, Andrew
    Jul 1, 2008
  3. Skybuck Flying

    Call oddities: &Test() vs &Test vs Test

    Skybuck Flying, Oct 4, 2009, in forum: C Programming
    Replies:
    1
    Views:
    854
    Skybuck Flying
    Oct 4, 2009
  4. bnp
    Replies:
    4
    Views:
    435
  5. noon

    regex failing

    noon, May 30, 2008, in forum: Javascript
    Replies:
    3
    Views:
    87
    Thomas 'PointedEars' Lahn
    May 30, 2008
Loading...

Share This Page