Javascript Validation Input and Output In Different Areas
I have a simple form with 2 fields. I already have PHP validation set up, but im implementing Javascript validation too.

My function for testing against my regex is sort of working. But nomatter what I type in the form it always gives me the same answer. I am calling this function during the onsubmit of a form.

    <script type="text/javascript" language="javascript">
       function validateIGN(ign) {
           var validign = /^[a-zA-Z0-9]{1,30}$/;
           if (!validign.test(ign)) {
           alert("invalid ign!");
       }
       else {
       	alert("valid ign!")
       }
       }
       </script>



Once I get this working, I would love some help getting it to check during the typing and not just onsubmit. I want the input and output to be two different areas. The input would be the form, and the output would be a div beside it; hopefully invisible until there is an error. 

Here is the relevant form information,



    <form name= "newsletter" class="newsletter" action="doNewsletter.php" onsubmit="return validateIGN();" method="post">

Thanks! 
Javascript Validation Input and Output In Different Areas
===

I have a simple form with 2 fields. I already have PHP validation set up, but im implementing Javascript validation too.

My function for testing against my regex is sort of working. But nomatter what I type in the form it always gives me the same answer. I am calling this function during the onsubmit of a form.

    <script type="text/javascript" language="javascript">
       function validateIGN(ign) {
           var validign = /^[a-zA-Z0-9]{1,30}$/;
           if (!validign.test(ign)) {
           alert("invalid ign!");
       }
       else {
       	alert("valid ign!")
       }
       }
       </script>



Once I get this working, I would love some help getting it to check during the typing and not just onsubmit. I want the input and output to be two different areas. The input would be the form, and the output would be a div beside it; hopefully invisible until there is an error. 

Here is the relevant form information,



    <form name= "newsletter" class="newsletter" action="doNewsletter.php" onsubmit="return validateIGN();" method="post">

Thanks! 