Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > regex test failing in form validation

Reply
Thread Tools

regex test failing in form validation

 
 
lancemiller777
Guest
Posts: n/a
 
      05-31-2009
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.
 
Reply With Quote
 
 
 
 
Eric Bednarz
Guest
Posts: n/a
 
      05-31-2009
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.
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      05-31-2009
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
 
Reply With Quote
 
Dr J R Stockton
Guest
Posts: n/a
 
      06-01-2009
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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How make regex that means "contains regex#1 but NOT regex#2" ?? seberino@spawar.navy.mil Python 3 07-01-2008 03:06 PM
regex failing noon Javascript 3 05-30-2008 08:26 PM
anyURI validation failing in Xerces-J dfielder@gmail.com XML 3 11-12-2005 05:15 PM
Form Validation Problem...Persisiting form fields on validation failure. bnp Javascript 4 05-12-2004 12:16 PM
test test test test test test test Computer Support 2 07-02-2003 06:02 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57