

 
// JavaScript Document
function trim(str)
{
  return str.replace( /^ +/, "" ).replace( / +$/, "" );
}
function istxtemail(pmStr)
{
 /******************************
 // @pmStr = String contain email
 ******************************/
 pmStr  = trim(pmStr); //#-- trim the string
 pmStr  = pmStr.replace(/\r\n|\r|\n/g, ''); 
 pmStr  = pmStr.replace(/\r\n/g,'');
 pmStr  = pmStr.replace(/\r/g,'');
 pmStr  = pmStr.replace(/\n/g,''); 
 
 if (pmStr == "") return false;
 if (pmStr.length > 50) return false;
 if (!isRegExpSupported()) return (pmStr.indexOf(".") > 2) && (pmStr.indexOf("@") > 0); //#-- is regular expressions supported
 //if the email does not have @ and . then return false
 if(pmStr.indexOf('@') == -1 || pmStr.indexOf('.') == -1 || pmStr.indexOf(' ') != -1)
  return false;
 var vPattern = "^[A-Za-z0-9](([_\\.\\-]?[a-zA-Z0-9_]+)*)@([A-Za-z0-9]+)(([\\_.\\-]?[a-zA-Z0-9]+)*)\\.([A-Za-z]{2,})$";
 var vRegExp = new RegExp(vPattern);
 return (vRegExp.test(pmStr));
}
function isRegExpSupported()
 {
  //#-- are regular expressions supported?
   if (window.RegExp)
   {
    //#-- assign expression
     var vTempStr = "a";
     var vTempReg = new RegExp(vTempStr);
    
    //#-- return status
     return (vTempReg.test(vTempStr));
   }
  
  //#-- return status
   return (false);
 } //#-- close of isRegExpSupported()

