tags:

views:

62

answers:

1

Possible Duplicate:
Post Method Not giving Alerts like planned?

Javascript:

function isAlphanumeric(elem, helperMsg){
    var alphaExp = /^[0-9a-zA-Z]+$/;
    if(elem.value.match(alphaExp)){
        return true;
    } else {
        alert(helperMsg);
        elem.focus();
        return false;
    }
}

function isGoodPhrase(elem,helperMsg){
    var badPhrase=/EPW|ESW|\s/;
    if (elem.value.match(badPhrase)){
        alert(helperMsg);
        elem.focus();
        return false;
    } else {
        return true;
    }
}

function checkInput(id)    {
    return isAlphanumeric(document.getElementById(id),'Your Submission Contained Invalid Characters')
        && isGoodPhrase(document.getElementById(id), 'Please Enter A Correct Friend Code!');
    }

    </script>

And HTML

    <form action="" method="post">
    <div align="center"><legend>Add a Code</legend>
    <label for="code"></label>
    <input type="text" name="code" id="code" maxlength="10" />
    <input type='button' onclick="return checkInput('code');" value='Check Field' />
    </form>
    </div>
A: 

alerts are working normally, i tested them.

Seams that the problem that you are testing with the right values that does not match the regex to see the alerts

Amr ElGarhy
to confirm above, just put alerts before the return true...
klabranche