Checking form for special characters in JavaScript.
<p>I am trying to make a function that checks for special characters such as !@#$%^&amp;*~ when I input a password. I've been using regular expressions to check for everything else, but does anyone know how I can make it so the function checks the password for at least one of these special characters? </p>

<p>Here's what I have:</p>

<pre><code>function validateEmail(email)
{
    var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,3}$/;  
    return emailPattern.test(email);  
}

function validatePassword(password)
{
    var passwordPattern = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])./;
    return passwordPattern.test(password)
}

function validate()
{
    var email = user.email.value;
    if(validateEmail(user.email.value))
    user.validEmail.value = "OK";
    else
        user.validEmail.value = "X";
    if(validatePassword(user.password.value))
        user.validPassword.value = "OK";
    else
        user.validPassword.value = "X";
}
</code></pre>
