PDA

View Full Version : Form validating...


cortic
09-28-2002, 02:50 PM
I need to make sure there is no code that could mess up the page (or cgi), there is quite a few fields in the form, but I only need to check name and email fields (for validity- within reason & tags and things) the 'name' field will be displayed on the page and the email field will go into a cookie.

I checked a lot of tutorials and references and couldn't find much about this, there's a script I found, checks emails, uses:

var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))

Ok, I know what test does (but I didn't think you could test for more than one thing at a time), I cant figure out the info in the filter, could someone explain this or point me in the direction of a tutorial/reference that explains this?

adios
09-28-2002, 05:27 PM
http://www.webreference.com/js/column5/index.html
http://developer.netscape.com/docs/manuals/js/client/jsguide/regexp.htm
http://tech.irt.org/articles/js049/

whammy
09-28-2002, 05:45 PM
Welcome to the extremely powerful world of Regular Expressions! :)

I don't know what I ever did without them.

Of the above guides that adios posted, my favorite is:

http://developer.netscape.com/docs/manuals/js/client/jsguide/regexp.htm

:D