Open zilongxuan001 opened 6 years ago
你可以要求用户必须填写数据才能提交。
在input元素里机上required
input
required
<input type="text" required>
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css"> <style> .red-text { color: red; } h2 { font-family: Lobster, Monospace; } p { font-size: 16px; font-family: Monospace; } .thick-green-border { border-color: green; border-width: 10px; border-style: solid; border-radius: 50%; } .smaller-image { width: 100px; } </style> <h2 class="red-text">CatPhotoApp</h2> <p>Click here for <a href="#">cat photos</a>.</p> <a href="#"><img class="smaller-image thick-green-border" alt="A cute orange cat lying on its back. " src="https://bit.ly/fcc-relaxing-cat"></a> <p>Things cats love:</p> <ul> <li>cat nip</li> <li>laser pointers</li> <li>lasagna</li> </ul> <p>Top 3 things cats hate:</p> <ol> <li>flea treatment</li> <li>thunder</li> <li>other cats</li> </ol> <form action="/submit-cat-photo"> <input type="text" required placeholder="cat photo URL"> <button type="submit">Submit</button> </form>
没有填内容就提交
填写内容提交后结果
https://www.freecodecamp.org/challenges/use-html5-to-require-a-field
介绍
你可以要求用户必须填写数据才能提交。
方法
在
input
元素里机上required
代码
结果显示
没有填内容就提交
填写内容提交后结果
来源
https://www.freecodecamp.org/challenges/use-html5-to-require-a-field