当我使用validate.js添加了表单验证后,它的验证就很好了,并显示了验证消息。但是输入type =“ submit”的值在操作页面结构中显示两次。
对于Illustrate,我有两个.cfm文件,index.cfm具有带验证的简单形式,而actionview.cfm具有
在HTML和jQuery验证代码中,在index.cfm中
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery validation plug-in - main demo</title>
<link rel="stylesheet" href="css/screen.css">
<script src="../lib/jquery.js"></script>
<script src="../dist/jquery.validate.js"></script>
<script>
$.validator.setDefaults({
submitHandler: function() {
form.submit();
}
});
$(document).ready(function() {
$("#commentForm").validate();
});
</script>
<style>
#commentForm {
width: 500px;
}
#commentForm label {
width: 250px;
}
#commentForm label.error, #commentForm input.submit {
margin-left: 253px;
}
</style>
</head>
<body>
<div id="main">
<h1 id="banner"><a href="https://jqueryvalidation.org/">jQuery Validation Plugin</a> Demo</h1>
<p>Default submitHandler is set to submitting the form</p>
<form class="cmxform" id="commentForm" method="post" action="actionView.cfm">
<fieldset>
<legend>Please provide your name, email address (won't be published) and a comment</legend>
<p>
<label for="cname">Name (required, at least 2 characters)</label>
<input id="cname" name="name" minlength="2" type="text" required>
</p>
<p>
<label for="cemail">E-Mail (required)</label>
<input id="cemail" type="email" name="email" required>
</p>
<p>
<label for="curl">URL (optional)</label>
<input id="curl" type="url" name="url">
</p>
<p>
<label for="ccomment">Your comment (required)</label>
<textarea id="ccomment" name="comment" required></textarea>
</p>
<p>
<input class="submit" type="submit" name="submit" value="Submit">
</p>
</fieldset>
</form>
</div>
</body>
</html>
在actionView.cfm中,
<cfdump var="#form#" />
在这里,我给出了表单和转储结构的屏幕截图:
示例表格
转储结构,
在转储的结构中,“提交”按钮的值为“ Submit,Submit”。但是通常我已经提交了显示“提交”的表格。我不确定为什么会这样吗?
有什么我想念的吗?我非常感谢有人解释为什么它显示两次?
谢谢!