<?php
@package@version
function order_a_website_function()
{
echo '<script language="Javascript" type="text/javascript">';
echo '<!--';
echo "\n";
echo 'function count(str,countMe)';
echo '{';
echo ' var count = 0;';
echo ' for (var i = 0; i<str.length; i++)';
echo ' {';
echo ' if (str.charAt(i) == countMe)';
echo ' {';
echo ' count++;';
echo ' }';
echo ' }';
echo ' return count;';
echo '}';
echo "\n";
echo 'function validateForm()';
echo '{';
echo ' var fname = document.forms["myForm"]["fname"].value;';
echo ' if ((fname == null) || (fname == ""))';
echo ' {';
echo ' alert("Error #1: First name field is missing");';
echo ' return false;';
echo ' }';
echo ' var lname = document.forms["myForm"]["lname"].value;';
echo ' if ((lname == null) || (lname == ""))';
echo ' {';
echo ' alert("Error #2: Last name field is missing");';
echo ' return false;';
echo ' }';
alert echo ' var y = document.forms["myForm"]["email"].value;';
echo ' if ((y == null) || (y == ""))';
echo ' {';
echo ' alert("Error #3: Email field is missing");';
echo ' return false;';
echo ' }';
echo ' var z = count(y,\'@\');';
echo ' if (z == 0)';
echo ' {';
echo ' alert("Error #4: Email address is missing a @ character");';
echo ' return false;';
echo ' }';
echo ' if (z > 1)';
echo ' {';
echo ' alert("Error #5: Email address has too many @ characters");';
echo ' return false;';
echo ' }';
echo ' var pattern = /^[\w\.\-]+@([\w\-]+\.)+[a-zA-Z]+$/;';
echo ' if (!pattern.test(y))';
echo ' {';
echo ' alert("Error #6: Invalid email address");';
echo ' return false;';
echo ' }';
echo ' var dob = document.forms["myForm"]["dob"].value;';
alert echo ' if ((dob != null) && (dob.length == 10))';
echo ' {';
echo ' if ((dob[0] < \'0\') || (dob[0] > \'9\'))';
echo ' {';
echo ' alert("Error #7: Invalid date of birth field");';
echo ' return false;';
echo ' }';
echo ' if ((dob[1] < \'0\') || (dob[1] > \'9\'))';
echo ' {';
echo ' alert("Error #8: Invalid date of birth");';
echo ' return false;';
echo ' }';
echo ' if ((dob[2] < \'0\') || (dob[2] > \'9\'))';
echo ' {';
echo ' alert("Error #9: Invalid date of birth field");';
echo ' return false;';
echo ' }';
echo ' if ((dob[3] < \'0\') || (dob[3] > \'9\'))';
echo ' {';
echo ' alert("Error #10: Invalid date of birth field");';
echo ' return false;';
echo ' }';
echo ' if (dob[4] != \'/\')';
echo ' {';
echo ' alert("Error #11: Invalid date of birth field");';
echo ' return false;';
echo ' }';
echo ' if ((dob[5] < \'0\') || (dob[5] > \'9\'))';
echo ' {';
echo ' alert("Error #12: Invalid date of birth field");';
echo ' return false;';
echo ' }';
echo ' if ((dob[6] < \'0\') || (dob[6] > \'9\'))';
echo ' {';
echo ' alert("Error #13: Invalid date of birth field");';
echo ' return false;';
echo ' }';
echo ' if (dob[7] != \'/\')';
echo ' {';
echo ' alert("Error #14: Invalid date of birth field");';
echo ' return false;';
echo ' }';
echo ' if ((dob[8] < \'0\') || (dob[8] > \'9\'))';
echo ' {';
echo ' alert("Error #15: Invalid date of birth field");';
echo ' return false;';
echo ' }';
echo ' if ((dob[9] < \'0\') || (dob[9] > \'9\'))';
echo ' {';
echo ' alert("Error #16: Invalid date of birth field");';
echo ' return false;';
echo ' }';
echo ' }';
echo ' else';
echo ' {';
echo ' if (dob.length != 0)';
echo ' {';
echo ' alert("Error #17: Date of birth field is the wrong length. Should be 10 characters wide");';
echo ' return false;';
echo ' }';
echo ' }';
---------------------------------------------------------------- echo ' var t = document.forms["myForm"]["title"].value;';
echo ' if ((t == null) || (t == ""))';
echo ' {';
echo ' alert("Error #18: The title of your website is missing");';
echo ' return false;';
echo ' }';
---------------------------------------------------------------- echo ' var m = document.forms["myForm"]["message1"].value.trim();';
echo ' if ((m == null) || (m == ""))';
echo ' {';
echo ' alert("Error #19: The first page of your website is missing");';
echo ' return false;';
echo ' }';
echo ' return true;';
echo '}';
echo '' echo "\n";
echo '</script>';
}
?>