Validation issue

Hi,

I am trying to validate a field that is required and also must only contain alphanumeric characters, but I can only get teh required part to work.

Any ideas what I have wrong?

This is my code:


function validateForm()
{
var x=document.forms["snazzyForm"]["textfield"].value;
if (x==null || x=="")
  {
  alert("First name must be filled out");
  return false;
  }

function checkkey(v) {
if (/\\W/.test(v.value)) {
alert("Please enter alphanumerics only");
return false;
}
return true;
}


}

and


<form  name="snazzyForm" action="index.html" method="POST" onsubmit="return (validateForm() && checkkey(this))">
<input type="text" name="textfield"   />
</form>

If you indent your code correctly, you’ll see that the checkkey function is inside the validateForm function right now.