首页
极刻
圈子
教程
开源
极客社区
写文章
发极刻
建圈子
发项目
登录 / 注册
返回教程:Javascript 参考手册
TRY RUN / 在线示例
Javascript 参考手册 尝试一下
Javascript 参考手册 尝试一下
源代码
运行
<!DOCTYPE html> <html> <body> <form action="form_action.asp"> 月: <input type="month" id="myMonth" name="bdaymonth"> <input type="submit" value="提交"> </form> <p>点击 "点我" 按钮设置 month 字段的 required 属性。</p> <p><strong>提示:</strong> 在点击 "点我" 按钮之前或之后点击 "提交" 按钮来查看效果。</p> <button onclick="myFunction()">点我</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myMonth").required = true; document.getElementById("demo").innerHTML = "required 属性已设置。 month 字段为表单的必填字段。"; } </script> </body> </html>
运行结果