javascript - 如何在表单中的字段下方创建警报?

标签 javascript html css

问题:我有表单,整体运行良好。但是,我想创建一个警报,显示在其为空的字段下方。

表单如下所示:

enter image description here

而不是像这样显示警报:

enter image description here

我想要像下面这样的警报:

enter image description here

我将如何实现这一目标?

最佳答案

如果你想要像图片中那样的默认 html5 警报,你需要:

  • 1。通过执行
     at the top of the page
  • 2. Add the required attribute to the input

to add it do this:

<input type="text" required>
确保您指定它是 html5

这应该可行

关于javascript - 如何在表单中的字段下方创建警报?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41753385/

相关文章:

javascript - Moment Timezone 返回正确的时区但拼写错误

javascript - 如何在javascript中为函数分配参数而不执行它?

css - 你应该如何使用 CSS 水平居中元素?

javascript - 脚本添加 iframe 内容在 chrome 中没有用户代理样式

javascript - 数据表页面加载问题

javascript - 无法在 onbeforeunload 事件中自定义消息

javascript - 从动态表单生成创建 JSON

jquery - 如何使用jquery用动态元素替换标签

html - css 粗体第一个字

链接到另一个 html 的 html