Home  >  Article  >  Web Front-end  >  js supports verification of mobile phone numbers starting with 158 and 159_form effects

js supports verification of mobile phone numbers starting with 158 and 159_form effects

WBOY
WBOYOriginal
2016-05-16 19:13:091499browse

Added verification for mobile phone numbers starting with 158 and 159.

Copy code The code is as follows:

//Remove the leading and trailing spaces of the string
String. prototype.Trim = function() {
var m = this.match(/^s*(S (s S )*)s*$/);
return (m == null) ? "" : m[1];
}
//Verify legal mobile phone number
String.prototype.isMobile = function() {
return (/^(?:13d|15[89])-? d{5}(d{3}|*{3})$/.test(this.Trim()));
}


should instance:
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn