View Full Version : Email validation with javascript

12-02-2009, 02:41 PM
This are my codes..

var add = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var email = form.txtEmail.value;
if (add.test(email) = false)
alert("Please enter a valid email.");
return false;
return true;

bt it wun work.. pls help..

12-02-2009, 05:44 PM
See, what you've done there is... well, several things.

Firstly, you've dropped a question containing no reference to any known javascript frameworks, into a forum for javascript frameworks.

Secondly, you've posted a tantalising snippet of code; an appetite-whetter, the javascript equivalent of a saucy flash of leg, but no indication of how, where or when this code runs, or what you're expecting it to do when it does.

And finally, you've signed off with that most helpful of requests for aid: "It don't work".

I'd suggest a brief trip to the posting guidelines (http://www.codingforums.com/postguide.htm), followed by a revisitation of your request. Try to include some as much helpful information as you can. This may include, but is not necessarily limited to:

A link to where we can see the thing running.
An expanded code snippet, illustrating how the code is being called and what is being sent to it when it is.
A summary of what you'd like to happen, and a description of what actually happens.
Some punctuation.