[Js practice] Determine whether the mobile phone number entered by the user is an 11-digit number. If it is not a pure number of 11 digits, it will prompt the user to input an error. If yes, it will prompt the input to be correct.

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>手机号码验证</title>
</head>
<body>
    <script>
		var sjhm=prompt("请输入你的手机号码");
		if (sjhm.length!=11){
			alert("请输入11位手机号");
		}else{
			if (isNaN(sjhm)) {
				alert("输入的手机号必须是11位数字");
			}else{
				alert("号码输入正确");
			}
		}
	</script>
</body>
</html>

 

Guess you like

Origin blog.csdn.net/qq_39799094/article/details/109030155