﻿function Form1_Validator(theForm)
{

  if (theForm.Email.value == "")
  {
    alert("Anna vielä sähköpostiosoitteesi.");
    theForm.Email.focus();
    return (false);
  }
  
  if (theForm.RecEmail.value == "")
  {
    alert("Anna vielä vastaanottajan sähköpostiosoite.");
    theForm.RecEmail.focus();
    return (false);
  }
  
  var radioSelected = false;
  for (i = 0;  i < theForm.CardID.length;  i++)
  {
    if (theForm.CardID[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Valitse kortti.");
    return (false);
  }


  if (theForm.CardMessage.value == "")
  {
    alert("Kirjoita viesti.");
    theForm.CardMessage.focus();
    return (false);
  }

  if (theForm.CardMessage.value.length > 512)
  {
    alert("Viestisi voi olla korkeintaan 512 merkkiä.");
    theForm.CardMessage.focus();
    return (false);
  }
  return (true);
}