regex test failing in form validation

L

lancemiller777

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.
 
E

Eric Bednarz

lancemiller777 said:
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.
 
T

Thomas 'PointedEars' Lahn

Conrad said:
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
 
D

Dr J R Stockton

In comp.lang.javascript message <b6WdnQOXF7MVY7_XnZ2dnUVZ_sqdnZ2d@supern
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top