<!--

function checkData()
{
  var frm = document.frmSubscription;
  
  if (frm.txtName.value == "")
  {
    alert ("Please enter your \"Name\".");
    frm.txtName.focus();
    return false;
  }
 
  if (frm.txtAdd.value == "")
  {
    alert ("Please enter your \"Address\".");
    frm.txtAdd.focus();
    return false;
  }
  
  if (frm.txtPostalCode.value == "")
  {
    alert ("Please enter your \"Postal Code\".");
    frm.txtPostalCode.focus();
    return false;
  }
  
  if (frm.optState.value == "")
  {
    alert ("Please enter your \"State\".");
    frm.optState.focus();
    return false;
  }
  
  if (frm.txtContactNo1.value == "")
  {
    alert ("Please enter your \"Contact No. (H)\".");
    frm.txtContactNo1.focus();
    return false;
  }

  if (frm.txtContactNo2.value == "")
  {
    alert ("Please enter your \"Contact No. (H)\".");
    frm.txtContactNo2.focus();
    return false;
  }
  
  if (frm.txtIC.value == "")
  {
    alert ("Please enter your \"NRIC\".");
    frm.txtIC.focus();
    return false;
  }
  if (frm.txtAge.value == "")
  {
    alert ("Please enter your \"Age\".");
    frm.txtAge.focus();
    return false;
  }
  if (frm.txtDOB_day.value == "")
  {
    alert ("Please enter your \"Date of Birth\".");
    frm.txtDOB_day.focus();
    return false;
  }
  if (frm.txtDOB_month.value == "")
  {
    alert ("Please enter your \"Date of Birth\".");
    frm.txtDOB_month.focus();
    return false;
  }
  if (frm.txtDOB_year.value == "")
  {
    alert ("Please enter your \"Date of Birth\".");
    frm.txtDOB_year.focus();
    return false;
  }
 
  //dateStr = frm.txtDOB_day.value + "-" + frm.txtDOB_month.value + "-" + frm.txtDOB_year.value
  //alert (isDate(dateStr));
  if (isDate(frm.txtDOB_day.value, frm.txtDOB_month.value, frm.txtDOB_year.value) == false)
  {
	frm.txtDOB_day.focus()
  return false;
  }
 
   if (frm.txtOcc.value == "")
  {
    alert ("Please enter your \"Occupation\".");
    frm.txtOcc.focus();
    return false;
  }

  if (checkEmail(frm.txtEmail.value) == false)
  {
	frm.txtEmail.focus()
  return false;
  }

  myOption = -1;
  for (i=0; i<frm.radMethod.length; i++) {
  if (frm.radMethod[i].checked) {
	myOption = i;}
  }
  if (myOption == -1) {
    alert ("Please choose a Payment Method.");
	return false;
  }
  

  return true;
}

function checkEmail(str) {
  var at="@"
  var dot="."
  var lat=str.indexOf(at)
  var lstr=str.length
  var ldot=str.indexOf(dot)
  if (str.indexOf(at)==-1){
    alert("Invalid \"Email\" entered!");
  return false;}

  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
   alert("Invalid \"Email\" entered!");
  return false;}

  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
    alert("Invalid \"Email\" entered!");
  return false;}

  if (str.indexOf(at,(lat+1))!=-1){
    alert("Invalid \"Email\" entered!");
  return false;}

  if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
    alert("Invalid \"Email\" entered!");
  return false;}

  if (str.indexOf(dot,(lat+2))==-1){
    alert("Invalid \"Email\" entered!");
  return false;}

  if (str.indexOf(" ")!=-1){
    alert("Invalid \"Email\" entered!");
  return false;}
return true;
}

function validateNo(field) {
  var valid="0123456789"
  var ok = "yes";
  var temp;
  for (var i=0; i<field.value.length; i++) {
	temp = "" + field.value.substring(i, i+1);
	if (valid.indexOf(temp) == "-1") ok = "no";
	}
    if (ok == "no") {
	  alert("Invalid entry! Only numbers (0-9).");
	  field.focus();
	  field.select();
    }
}


// ******************************************************************
// This function accepts a string variable and verifies if it is a
// proper date or not. It validates format matching either
// mm-dd-yyyy or mm/dd/yyyy. Then it checks to make sure the month
// has the proper number of days, based on which month it is.

// The function returns true if a valid date, false if not.
// ******************************************************************

function isDate(day, month, year) {

//var datePat = /^(\d{1,2})(-)(\d{1,2})(-)(\d{4})$/;
//var matchArray = dateStr.match(datePat); // is the format ok?

/*if (matchArray == null) {
alert("Please enter date as dd-mm-yyyy.");
return false;
}*/

/*day = int(matchArray[1]); // p@rse date into variables
month = int(matchArray[3]);
year = int(matchArray[5]);*/

if (day < 1 || day > 31) { // check day range
alert("Day must be between 1 and 31.");
return false;
}

if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.");
return false;
}

if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Month "+month+" doesn`t have 31 days!")
return false;
}

if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day > 29 || (day==29 && !isleap)) {
alert("February " + year + " doesn`t have " + day + " days!");
return false;
}
}
return true; // date is valid
}

//-->