gpt4 book ai didi

javascript - 验证涉及文本区域的表单

转载 作者:行者123 更新时间:2023-11-28 19:10:19 25 4
gpt4 key购买 nike

我正在尝试使用jquery技术来验证Web表单(我实际上正在学习)。下载并引用我的代码中的文件后,即使分配了 REQUIRED 类属性,TEXTAREA 也顽固地拒绝验证。请有人帮忙。抱歉,如果这是微不足道的。代码如下:

<script type ="text/JavaScript" src = "jquery.js"></script>
<script type ="text/JavaScript" src ="jquery.validate.js"></script>
<script type ="text/JavaScript">
$(document).ready(function(){
$("#reg").validate();
})// end of ready()

来自代码:

<form id = 'reg' method ='post' action =''>
<label for 'username'>User Name **</label>
<input type ='text' name ='username' id ='usN' class = 'required' title = "Enter Your name"><br/>
<label for 'Address'> Address **</label>
<input type ='text' id ='addr' class = 'required' title = "Enter Your Address"><br/>
<label for 'comment'>Comment Below **</label>
br/> <textarea id ='comm' rows =5, cols = 18 class ='required' title = 'Make a comment'></textarea><br/>
<input type ='submit' id = 'button1' value = 'SEND'>
</form>

最佳答案

您必须为每个 input/textarea 元素添加唯一的 name 属性。

Markup recommendations

The name attribute is required for input elements, the validation plugin doesn't work without it.

关于javascript - 验证涉及文本区域的表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30831726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com