I'm having trouble getting the following scipt to work. It's a basic validation which validates the email, the confirms the email again. However it's not working. Can anyone see what I'm doing wrong?

Thanks!

Code:
<script type="text/javascript">
function validate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}


function checkEmail() {
var checkem = document.getElementById("em").value
with (field) {
  if (value != checkem) {
  alert(alerttxt);return false;
    }
  else
    {
    return true;
}
}
}


function validate_form(thisform)
{
with (thisform)
  {
if (validate_email(em,"Email must be valid!")==false)
  {em.focus();return false;}
else if (checkEmail(em2,"Confirm email must match")==false)
  {em2.focus();return false;}
  }
}
</script>


<form action="send.php" onSubmit="return validate_form(this)" method="post">
<div class="label">Email:*</div>
<input type="text" id="em" name="em" class="width_190" />
			  
<div class="label">Confirm email:*</div>
<input type="text" id="em2" name="em2" class="width_190" /> 
<input type="submit" />
</form>