html5 required pattern pattern是设置正则的地方,与js有所不同哦,
<!doctype html>
<html lang="en">
<head>
<meta charset=utf-8 />
<title>pattern</title>
</head>
<body>
<form>
<input required pattern="[0-9]{5}(-[0-9]{4})?|[a-za-z]{1,2}d{1,2}s?d[a-za-z]{1,2}" name=part title="a zip code or postcode in the format of 99999 or 99999-9999" >
<input type=submit>
</form>
</body></html>
时间: 2024-09-20 22:29:39