required 属性可以在 input、select 和 textarea 元素上使用。
示例您可以尝试运行以下代码来实现只读 属性 -
<!doctype html><html> <head> <title>html placeholder attribute</title> </head> <body> <h2>register</h2> <form action = "/new.php"> <input type = "text" placeholder = "student username" name = "name" required/><br> <input type = "submit" value = "submit"> </form> </body></html>
以上就是如何在html中指定在提交表单之前必须填写元素?的详细内容。
