1.required属性规定在提交之前要填写输入域(不能为空)。

  2.代码

    <body>
<form>
账号:<input type="text" required="required"><br/>
密码:<input type="password" required="required"><br/>
<input type="submit" value="登陆">
</form>
</body>
</html>

  3.效果图

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUYAAABzCAIAAABrdTwNAAANZUlEQVR4nO2d63PTVhqH5c72/yEsnqH+L9puSvOhgXZ3PUyZMvlQhrIMs7MtdFumOzGlM73R4cteaCDbaWk97AbYwgIZQjbEVnAZKzTgJLYVy1ZtSY6to0T7Qbbji2TZsX1sS79nzkx8keQjx4/eo6Oj9zBT1x+ioKA4pjA6AMBBQGkAHAWUBsBRQGkAHAWUBsBRQGkAHMXAK729rROiK4ouinoqpW9soAxZSaV0UdQVRSdE397u9+/J+Qy80oTo6bTOsvrMjD49rU9NoQxZmZ7WZ2Z0ltXTaZ2Qfv+enM/AK60oOsvqFy/qExP62Jg+OooyZGVsTJ+Y0C9e1FlWV5R+/56cz8ArLYr6zIw+MbFy6I2ZG7cvT19FGa4yc+P2yqE39IkJfWZGF8V+/56cz8ArnUrp09P62FhsdYMXful3bUDb8MIv3EpcHxvTp6f1VKrf1XE+bSvNBXyMP9iLqpizsaFPTemjo7HVDXofCroKtxLXR0f1qSl9A//EntNEaS7gY2rwBTgTpYN+X4DrXQUblGaYgW9ZgFqgNE1slK7IywV8ZkpzAR/j8wd3lA76maa0rT+UHn6gNE06UZoL+Jj6RnjQ38Tapm9aAKWHHyhNE3ulDQ8blDbzWYfSwAQoTZNdKm3ZSdZRw5sL+BqWgNLDD5Smya6jtAUdRWko7UygNE3aUzpgFYN7d1kLSg8/UJomu43SledVC7dDy8cAKD38QGmatKR0tcLV3WPmXu6mE8waKD38QGma2CpdH5UrKls4XR++OwVKDz9Qmia2ehhd2LWDS0rPgn6TBnS3x5pA6eEHStPETo+gn/EFglXXoGuCs6nUTTfWdHH0eDsTKE2T5nrs+Bv0M/XdY74AVwrKLVpte8cHlHYmUJomNufSVX6VJC43rHf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