View Full Version : js prompt keeps appearing?!

Aug 18th, 2006, 08:49 PM
ok, i have a supersimple js prompt to get a valid email addy:

function getEmail(){
var em=prompt('Please enter a valid email address','[email protected]');
if (em!=null && em!=''){//not empty
if (validateEmail(em)){//is valid email
alert("successfully captured!");

function validateEmail(email) {
//Validating the email field
var re = /^(([^<>()[\]\\.,;:\[email protected]\"]+(\.[^<>()[\]\\.,;:\[email protected]\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (! email.match(re)) {
alert("Invalid email address");
return false;
return true;

But when I click the button with the getEmail() call it displays the prompt, I hit OK and then it appears again, and again , and again.... it only goes away if i choose Cancel.

The "successfully captured!" alert fires when I choose OK though, so I know the functions are working?

Thanks y'all for any insight.


Aug 18th, 2006, 09:46 PM
It works for me. How are you calling it? What browser are you testing with?