Javascript basics: regular expression (1): determine the phone number

1. Determine whether it is a phone number

function isPhone(tel) {
    
     
	var regx = /^1[34578]\d{9}$/; 
	return regx.test(tel);
 }

Syntax: regex.test(tel)

The parameter is a string value, it returns true or false, if it matches, it returns true, otherwise it returns false.

Guess you like

Origin blog.csdn.net/imagine_tion/article/details/111086211