[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Vtiger/resources/validator/ -> EmailValidator.js (source)

   1  /*+***********************************************************************************
   2   * The contents of this file are subject to the vtiger CRM Public License Version 1.0
   3   * ("License"); You may not use this file except in compliance with the License
   4   * The Original Code is:  vtiger CRM Open Source
   5   * The Initial Developer of the Original Code is vtiger.
   6   * Portions created by vtiger are Copyright (C) vtiger.
   7   * All Rights Reserved.
   8   *************************************************************************************/
   9  Vtiger_BaseValidator_Js("Vtiger_EmailValidator_Js",{},{
  10      error: "",
  11      validate: function(){
  12          var fieldValue = this.fieldInfo.val();
  13          var tfld = fieldValue.replace(/^\s+/,'').replace(/\s+$/,'');
  14          var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
  15          var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
  16  
  17          if (fieldValue.value == "") {
  18  
  19              this.getEmptyEmailError();
  20  
  21          } else if (!emailFilter.test(tfld)) {
  22  
  23              this.getInvalidEmailError();
  24  
  25          } else if (fieldValue.match(illegalChars)) {
  26  
  27              this.getIllegalCharacterEmailError();
  28          
  29          }
  30      },
  31  
  32      getEmptyEmailError: function(){
  33          this.error = "You didn't enter an email address.\n";
  34          return this.error;
  35      },
  36  
  37      getInvalidEmailError: function(){
  38          this.error = "Please enter a valid email address.\n";
  39          return this.error;
  40      },
  41  
  42      getIllegalCharacterEmailError: function(){
  43          this.error = "The email address contains illegal characters.\n";
  44          return this.error;
  45      }
  46  
  47  
  48  })


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1