home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 August - Disc 1 / PCNET_CD_2006_08_1.iso / shareware / SafeFiles-Win.exe / root / magnet10 / scripts.js < prev    next >
Encoding:
Text File  |  2006-06-29  |  2.6 KB  |  116 lines

  1. <!--// hide from old browsers
  2.     var whitespace = " \t\n\r";
  3.     var digitsInCC1 = 13;
  4.     var digitsInCC2 = 15;
  5.     var digitsInCC3 = 16;
  6.     var digitsInEXP = 4;
  7.     
  8.  
  9.    function rf_isEmpty(str) {
  10.     return ((str == null) || (str.length == 0));
  11.    }
  12.  
  13.      function rf_isDigit(chr) {
  14.      return ((chr >= "0") && (chr <= "9"));
  15.    }
  16.  
  17.    
  18.     function rf_isInteger(str) {
  19.     var i;
  20.     if (rf_isEmpty(str))
  21.         return false;
  22.     for (i = 0; i < str.length; i++) {
  23.         var chr = str.charAt(i);
  24.         if (!rf_isDigit(chr))
  25.             return false;
  26.     }
  27.     return true;
  28.   }
  29.    
  30.      function rf_isCC(str) {
  31.      if (rf_isEmpty(str)) 
  32.      return false;
  33.      return (rf_isInteger(str) && ((str.length == digitsInCC1) || (str.length == digitsInCC2) || (str.length == digitsInCC3)));
  34.    }
  35.  
  36.      function rf_isEXP(str) {
  37.      if (rf_isEmpty(str)) 
  38.      return false;
  39.      return (rf_isInteger(str) && ((str.length == digitsInEXP)));
  40.    }
  41.  
  42.    function rf_isWhitespace(str) {
  43.     var i;
  44.     if (rf_isEmpty(str))
  45.      return true;
  46.     for (i = 0; i < str.length; i++) {
  47.      var chr = str.charAt(i);
  48.      if (whitespace.indexOf(chr) == -1)
  49.       return false;
  50.     }
  51.     return true;
  52.    }
  53.    
  54.    /////////////////////
  55.  
  56.  
  57.     
  58.     ////////////////
  59.  
  60.     function Validator(theForm)    {
  61.    
  62.      if (rf_isWhitespace (document.forms[0].to_email.value))
  63.    {
  64.            alert("You didn't enter where you'd like the links sent")
  65.            theForm.to_email.focus();
  66.            return (false);
  67.    }
  68.   
  69.     // check the EMAIL format
  70.     if (!isEmail(document.forms[0].to_email))
  71.     {
  72.         alert("Please verify that the receiver's email address is in the proper format - name@company.com.");
  73.         theForm.to_email.focus();
  74.         return (false);
  75.     }
  76.   
  77.  
  78.     // check the EMAIL format
  79.     if (!isEmail(document.forms[0].cc_email)&& !rf_isWhitespace (document.forms[0].cc_email.value))
  80.     {
  81.         alert("Please verify that the cc email address is in the proper format - name@company.com.");
  82.         theForm.cc_email.focus();
  83.         return (false);
  84.     }
  85.     
  86.          if (rf_isWhitespace (document.forms[0].from_email.value))
  87.    {
  88.             alert("You didn't enter your email address.")
  89.            theForm.from_email.focus();
  90.            return (false);
  91.    }
  92.   
  93.     // check the EMAIL format
  94.     if (!isEmail(document.forms[0].from_email))
  95.     {
  96.         alert("Please verify that your email address is in the proper format - name@company.com.");
  97.         theForm.from_email.focus();
  98.         return (false);
  99.     }
  100.  
  101.   
  102. }
  103.  
  104.  
  105. function isEmail(frmField)
  106. {   
  107.     var str = frmField.value;
  108.     if (str.indexOf ('@',0) == -1 || str.indexOf ('.',0) == -1)
  109.         return false;      
  110.     else
  111.         return true;      
  112. }
  113.  
  114.  
  115.  
  116. //-->