js格式驗證

在路上等發表於2020-11-07
	function  checkTel(tel)
			{
			    var  mobile = /^1[3|5|8]\d{9}$/ , phone = /^0\d{2,3}-?\d{7,8}$/;
			    return  mobile.test(tel) || phone.test(tel);
			}
			console.log(checkTel( '13590871234' ),"13590871234");      //true
			console.log(checkTel( '020-12345678' ),"020-12345678");     //true
			console.log(checkTel( '1346118' ),"1346118");             //false

手機號驗證(固話)

相關文章