我有一个由Nicedit转换为富文本编辑器的表单。此外,我已将Jquery验证插件应用于表单,除了textarea标记外,一切正常。 textarea标记没有响应jquery验证插件。当我单击提交按钮而不在textarea中输入文本时,表单将被提交。如果有人可以帮助我,我会很高兴的。 以下是我的代码:
<!DOCTYPE html>
<head>
<script src="nicEdit.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<style>
body
{
font-family:Gotham,'sans-serif';
}
</style>
</body>
</head>
<body>
<form id="ruebenform" novalidate="novalidate">
Firstname: <input name="firstname" id="firstname">
<textarea id="thetextarea" rows="5" cols="45"></textarea>
<button type="submit">Submit</button>
</form>
<script type="text/javascript">
new nicEditor({maxHeight : 50}).panelInstance('thetextarea');
</script>
//Jquery validation script
<script>
$("#ruebenform").validate({
rules:{
firstname: {
required: true,
minlength: 2
},
thetextarea: {
required: true,
minlength: 2
}
},
messages: {
firstname: {
required: "Please enter a title",
minlength: "At least 2 characters"
},
thetextarea: {
required: "Please enter a description",
minlength: "At least 2 characters"
}
},
submitHandler: function(form) { return false; }
});
</script>
</body>
</html>