GNU   davin.50webs.com/research
Bringing to you notes for the ages

       Main Menu          Research Projects         Photo Album            Curriculum Vitae      The Greatest Artists
    Email Address       Computer Games          Web Design          Java Training Wheels      The Fly (A Story)   
  Political Activism   Scruff the Cat       My Life Story          Smoking Cessation          Other Links      
Debugging Macros     String Class I     Linked List System I Java for C Programmers Naming Convention
    String Class II         How I use m4              Strings III                 Symmetrical I/O             Linked Lists II     
Run-Time Type Info   Virtual Methods      An Array System        Science & Religion            Submodes       
  Nested Packages      Memory Leaks    Garbage Collection      Internet & Poverty      What is Knowledge?
Limits of Evolution   Emacs Additions      Function Plotter           Romantic Love        The Next Big Thing
    Science Fiction     Faster Compilation Theory of Morality         Elisp Scoping               Elisp Advice      
  S.O.G.M. Pattern       Safe Properties         School Bullying          Charisma Control          Life and Death    
     Splitting Java          Multiple Ctors       Religious Beliefs         Conversation 1           Conversation 2    
   J.T.W. Language    Emacs Additions II      Build Counter             Relation Plotter          Lisp++ Language  
  Memory Leaks II   Super Constructors CRUD Implementation Order a Website Form There Is An Afterlife
More Occam's Razor C to Java Translator Theory of Morality II


order-a-website-functions.php

    
<?php

/*

@package Order A Website
  @version 1.0

Plugin URL: http://davin.50webs.com/research/2014/aoawf.html
  Description: Miscellaneous functions for the Order A Website wordpress plugin.
  Author: Davin Pearson
  Author URL: <http://davin.50webs.com>

LIMITATION OF WARRANTY:

This file is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 3, or (at your option)
  any later version.

This file is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

You should have received a copy of the GNU General Public License
 along with this software, see the file COPYING.  If not, see:

http://www.gnu.org/licenses/gpl-3.0.txt
*/

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 '   }';
   //   echo '   x = x.trim();';
   //   echo '   if (count(x,\' \') == 0)';
   //   echo '   {';
   //   echo '      alert("Your name needs to have at least two words separated by a space");';
   //   echo '      return false;';
   //   echo '   }';
   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;';
   //echo '   alert("null.length");';
   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>';
}

?>
Back
| Main Menu | Research Projects | Photo Album | Curriculum Vitae | The Greatest Artists |
| Email Address | Computer Games | Web Design | Java Training Wheels | The Fly (A Story) |
| Political Activism | Scruff the Cat | My Life Story | Smoking Cessation | Other Links |
| Debugging Macros | String Class I | Linked List System I | Java for C Programmers | Naming Convention |
| String Class II | How I use m4 | Strings III | Symmetrical I/O | Linked Lists II |
| Run-Time Type Info | Virtual Methods | An Array System | Science & Religion | Submodes |
| Nested Packages | Memory Leaks | Garbage Collection | Internet & Poverty | What is Knowledge? |
| Limits of Evolution | Emacs Additions | Function Plotter | Romantic Love | The Next Big Thing |
| Science Fiction | Faster Compilation | Theory of Morality | Elisp Scoping | Elisp Advice |
| S.O.G.M. Pattern | Safe Properties | School Bullying | Charisma Control | Life and Death |
| Splitting Java | Multiple Ctors | Religious Beliefs | Conversation 1 | Conversation 2 |
| J.T.W. Language | Emacs Additions II | Build Counter | Relation Plotter | Lisp++ Language |
| Memory Leaks II | Super Constructors | CRUD Implementation | Order a Website Form | There Is An Afterlife |
| More Occam's Razor | C to Java Translator | Theory of Morality II
Last modified: Sun Sep 25 16:11:13 NZDT 2016
Best viewed at 800x600 or above resolution.
© Copyright 1999-2016 Davin Pearson.
Please report any broken links to