View Single Post
  #6 (permalink)  
Old February 18th, 2009, 02:46 PM
williamjwayne williamjwayne is offline
Registered User
 
Join Date: Feb 2009
Location: Ohio, USA
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Followup to my RegEx question ...

Thank you all for the responses!

My regrets for not listing all information. The information I was questioning is located on p.222 of JavaScript for Web Developers, Nicholas C. Zakas. In it the author discusses validating e-mail addresses using RegEx techniques. He discusses the major email formats and offers a RegEx validation solution:

function isValidEmail(sText) {
var reEmail = /^(?:\w+\.?)*\w+@(?:\w+\.)+\w+$/;
return reEmail.test(sText);
}

He then goes on to add in the next line:

"This function can be called like so:


alert(john.doe@somewhere.com); //outputs "true"

alert(john.doe@somewhere.); //outputs "false" "

(The underlining on the email addresses are not in the book but were added by default in this editor.)

And that is where my confusion comes in. I am unaware of how the function can be called given the code as laid out in the book. Of course the RegEx works but I don't see how the function can be invoked using just an alert. I thought it was just a typo but the errata pages for the book does not address it. Do you have any info that can shed light?

Regards,
Bill Wayne
Reply With Quote