猿问

HTML <input>必需的属性不起作用

我放置在表的一行中的必填属性似乎根本不起作用。


我尝试关闭和取消关闭输入标签,并将按钮类型更改为input type =“ submit”,但问题仍然存在。


<tr>

  <form action="">

    <td><input type="text" id="itn" required/></td>

    <td> <input type="text" id="prc" required/></td>

    <td> <input type="text" id="dt" required/></td>

    <td><input type="text" id="qn" required/></td>

    <td><input type="text" id="am" required/></td>

    <button type="button" onclick="add()" class="button button3">

      ADD

       </button>

</tr>

当我在谷歌浏览器中执行代码时,如果我错过任何字段,浏览器将不会显示任何警报。


婷婷同学_
浏览 219回答 2
2回答

宝慕林4294392

将表格放在表格中。这是一个基本示例和用法action。在add函数内部,您可以放置自定义验证器并使用ajax提交表单function add() {}<form action="add()">&nbsp; <table>&nbsp; &nbsp; <tr>&nbsp; &nbsp; &nbsp; <td><input type="text" id="itn" required/></td>&nbsp; &nbsp; &nbsp; <td> <input type="text" id="prc" required/></td>&nbsp; &nbsp; &nbsp; <td> <input type="text" id="dt" required/></td>&nbsp; &nbsp; &nbsp; <td><input type="text" id="qn" required/></td>&nbsp; &nbsp; &nbsp; <td><input type="text" id="am" required/></td>&nbsp; &nbsp; &nbsp; <td><button type="submit" class="button button3">&nbsp; &nbsp; &nbsp; ADD&nbsp; &nbsp; &nbsp; &nbsp;</button></td>&nbsp; &nbsp; </tr>&nbsp; </table>

慕姐8265434

试试这个代码<tr>&nbsp; &nbsp; <form action="">&nbsp; &nbsp; &nbsp; &nbsp; <td><input type="text" id="itn" required/></td>&nbsp; &nbsp; &nbsp; &nbsp; <td> <input type="text" id="prc" required/></td>&nbsp; &nbsp; &nbsp; &nbsp; <td> <input type="text" id="dt" required/></td>&nbsp; &nbsp; &nbsp; &nbsp; <td><input type="text" id="qn" required/></td>&nbsp; &nbsp; &nbsp; &nbsp; <td><input type="text" id="am" required/></td>&nbsp; &nbsp; &nbsp; &nbsp; <input type="submit" onclick="add()" class="button button3" value="ADD">&nbsp; &nbsp; </form></tr>
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答