Javascript String isMobile()

Description

Javascript String isMobile()

String.prototype.isMobile = function() { 
  return (/^(?:13\d|15[89])-?\d{5}(\d{3}|\*{3})$/.test(this.Trim())); 
} 
String.prototype.isTel = function() 
{ 
  return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/.test(this.Trim())); 
} 

String.prototype.Trim = function() { 
  var m = this.match(/^\s*(\S+(\s+\S+)*)\s*$/); 
  return (m == null) ? "" : m[1]; 
}



PreviousNext

Related