Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 





Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read

Web Design & Programming Discussion of web design, and server-side & client-side scripting

Reply
 
Thread Tools
Old 06-12-2008, 10:27 PM   #1 (permalink)
Registered User
 
Join Date: Jan 2008
Location: Townsville Australia
Posts: 27
OS: XP SP2

My System

Question date validations

function emailVal()
{
var strEmail = document.frmCheese.txtEmail.value; //value of entered email addres
var strExp = (/\w+[\.-]?\w+@\w+\.\w{3}(\.\w{2})?/) ; //string to test the email address...
var strReg = new RegExp(strExp,"i");


if (strReg.test(strEmail)) //email value checking using
{
checkPw();

}
else
{
window.alert(strReg + "\n" + strEmail );
window.alert("Your emailaddress is invalid. \nPlease enter a correct email address");
document.frmCheese.txtEmail.value = "";
document.frmCheese.txtEmail.focus();

}

}


For a tafe project I am trying to validate the date, the above is my code. Where is the mistake...

Wizz
wizzbone is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 06-14-2008, 02:35 AM   #2 (permalink)
Registered User
 
Join Date: Jan 2008
Location: Townsville Australia
Posts: 27
OS: XP SP2

My System

Confused email validation in JavaScript

Sorry guys after hours of trying to fix this relatively simple coding, my eyes and brains weren't working very well...

Yes I also had problems with date validation, but most of that is sorted, albeit not in a nice fashion... used if-statements instead of a nice for-loop...

back to this question I ofcourse meant a email validation not date validation.

I tried RegExp in different forms... but I could not get it to work, so I used .indexOf("@") so if there is an @ anywhere in the string, the email is valid.

I rather use the RegExp - looks much spiffi-er!

The following code should work, but it doesn't:
----------
var strEmail = document.frmCheese.txtEmail.value; //I checked the value of strEmail and the value of txtEmail is in it.

var strExp = ("\w+[\.-]?\w+@\w+\.\w{3}(\.\w{2})?") ; /I checked the value of strExp is there, but many "\" are missing?

var strReg = new RegExp(strExp,"i");


if (strReg.test(strEmail)) //does 'test' has to be something else?
-----------

if (strReg.test(strEmail)== true)
if (strReg.test("strEmail"))
- i tried didn't work and more variations!

strRegExp I had originally but I thought maybe a word that is used already...

According to my understanding this RegExp expression would allow:

some letters, "." or "-", more letters, "@" more letters "." 3 letters ("." 2 letters) - but optional.

If I could get this to work, I would replace 3 letters with (com | net | org | edu |...) etc, to get even better grades!

Now can anybody have a glans and the code and give me a hint where the mistake is?
I like to know before Wednesday if that is possible....

Wizz

Last edited by wizzbone : 06-14-2008 at 02:43 AM.
wizzbone is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
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

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



All times are GMT -7. The time now is 12:54 PM.



Copyright 2001 - 2008, Tech Support Forum

Search Engine Friendly URLs by vBSEO

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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82