[thelist] JavaScript: A Confusion

Scott Brady evolt at scottbrady.net
Tue Feb 26 15:30:01 CST 2002


The "!" operator means "not".

It's most often used in conditionals and function returns.

let's say you have a function, called "isValidEmail(theString)" which checks
to see if the given string is a valid e-mail address.  If it is, it returns
true.  if not, it returns false.

You want to alert the user if the e-mail address they entered in the textbox
"email" in the form called "form1" is NOT valid, so you'd do:

if (!isValidEmail(document.form1.email))
{
    alert('That e-mail address is not valid.');
    return false;
}

Does that make sense?

Scott
----------------------------------------------
Scott Brady
http://www.scottbrady.net/





More information about the thelist mailing list