Javascript if NOT statement

Is there such a thing as an IF NOT statement in javascript?

Yep, the negation operator is same as the C/C++ one: the ! mark. ie

var value1 = 9;

if (value1 != 8)
{
//if the above is TRUE, that is value1 IS NOT equal to 8 this will be executed

document.write("value1 is actually " + value1);

}

I’m not sure if what I am trying to do makes any sense.

I wanted to change the email validation below:

function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)@\w+([\.-]?\w+)(\.\w{2,3})+$/.test(myForm.emailAddr.value)){
return (true)
}
alert(“Invalid E-mail Address! Please re-enter.”)
return (false)
}

to fit into my checksubmit function (taking out the return true) to:

if NOT (/^\w+([\.-]?\w+)@\w+([\.-]?\w+)(\.\w{2,3})+$/.test(myForm.emailAddr.value))
{
alert(“Invalid E-mail Address! Please re-enter.”)
return (false)
}

I’m not sure how to do this using your suggestion

Just add the ! and extra ()'s like this:


if ([b]!([/b]/^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$/.test(myForm.emailAddr.value)[b])[/b])
{
 alert("Invalid E-mail Address! Please re-enter.")
  return (false)
}

Thanks! I found other code from devguru that I got to work, but learning this concept helps me more!