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:

PHP 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

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