【HTML5】使用正则表达式构造定制的输入框

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

<!DOCTYPE html>
 
<html>
 
<head>
 
<title>
</title>
 
</head>
 
<body>
 
<form id="myForm">
 
<fieldset>
 
<legend>Solution 4-8: Creating custom input types using regular expressions</legend>
 
<label> Insert a valid American Zip code:
 
<input type="text" name="ssn"
 
pattern="(\d{5}([\-]\d{4})?)"
 
title="Zip Code" />
 
</label>
 
<p><input type="submit" value="Check Zip code" /> </p>
 
</fieldset>
 
</form>
 
</body>
 
</html>