﻿// Script for filling out the Customize form for desktops

function Form1_Validator(theForm)
{

	  if (theForm.Featured_Price.value == "")
	  {
		    alert("Please enter a value for the \"Unit Price\" field.");
		    theForm.Featured_Price.focus();
		    return (false);
	  }

	  if (theForm.Featured_Price.value.length < 4)
	  {
		    alert("Veuillez s.v.p. mettre une quantité.");
		    theForm.Featured_Price.focus();
		    return (false);
	  }

	  var checkOK = "0123456789-$. \t\r\n\f";
	  var checkStr = theForm.Featured_Price.value;
	  var allValid = true;
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		    ch = checkStr.charAt(i);
		    for (j = 0;  j < checkOK.length;  j++)
		      if (ch == checkOK.charAt(j))
		        break;
		    if (j == checkOK.length)
		    {
		      allValid = false;
		      break;
		    }
	  }

	  if (!allValid)
	  {
		    alert("Please enter only digits, whitespace and \"$.\" characters in the \"Unit Price\" field.");
		    theForm.Featured_Price.focus();
		    return (false);
	  }

	  if (theForm.Unit_Price.value == "")
	  {
		    alert("Please enter a value for the \"Unit Price\" field.");
		    theForm.Unit_Price.focus();
		    return (false);
	  }

	  if (theForm.Unit_Price.value.length < 4)
	  {
		    alert("Please enter at least 4 characters in the \"Unit Price\" field.");
		    theForm.Unit_Price.focus();
		    return (false);
	  }

	  var checkOK = "0123456789-$. \t\r\n\f";
	  var checkStr = theForm.Unit_Price.value;
	  var allValid = true;
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		    ch = checkStr.charAt(i);
		    for (j = 0;  j < checkOK.length;  j++)
		      if (ch == checkOK.charAt(j))
		        break;
		    if (j == checkOK.length)
		    {
		      allValid = false;
		      break;
		    }
	  }

	  if (!allValid)
	  {
		    alert("Please enter only digits, whitespace and \"$.\" characters in the \"Unit Price\" field.");
		    theForm.Unit_Price.focus();
		    return (false);
	  }

	if (theForm.quantity.value == "")
	  {
		    alert("Please enter a value for the \"quantity\" field.");
		    theForm.quantity.focus();
		    return (false);
	  }

	  var checkOK = "1234567890\t\r\n\f";
	  var checkStr = theForm.quantity.value;
	  var allValid = true;
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		    ch = checkStr.charAt(i);
		    for (j = 0;  j < checkOK.length;  j++)
		      if (ch == checkOK.charAt(j))
		        break;
		    if (j == checkOK.length)
		    {
		      allValid = false;
		      break;
		    }
	  }
	  if (!allValid)
	  {
		    alert("Please enter only digits in the \"Quantity\" field.");
		    theForm.quantity.focus();
		    return (false);
	  }


	  if (theForm.GST.value == "")
	  {
		    alert("Please enter a value for the \"GST\" field.");
		    theForm.GST.focus();
		    return (false);
	  }

	  if (theForm.GST.value.length < 4)
	  {
		    alert("Please enter at least 4 characters in the \"GST\" field.");
		    theForm.GST.focus();
		    return (false);
	  }

	  if (theForm.GST.value.length > 11)
	  {
		    alert("Please enter at most 11 characters in the \"GST\" field.");
		    theForm.GST.focus();
		    return (false);
	  }

	  if (theForm.Total.value == "")
	  {
		    alert("Please enter a value for the \"Total_Order\" field.");
		    theForm.Total.focus();
		    return (false);
	  }

	  if (theForm.Total.value.length < 4)
	  {
		    alert("Please enter at least 4 characters in the \"Total_Order\" field.");
		    theForm.Total_Order.focus();
		    return (false);
	  }

	  if (theForm.Total.value.length > 11)
	  {
		    alert("Please enter at most 11 characters in the \"Total_Order\" field.");
		    theForm.Total_Order.focus();
		    return (false);
	  }

	  return (true);
}

