0
<script src="/Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery.validate.min.js" type="text/javascript"></script>
<link href="/CSS/jquery.wysiwyg.css" rel="stylesheet" type="text/css" />
<script src="/JS/jquery.wysiwyg.js" type="text/javascript"></script>
<script type="text/javascript" >
    $(document).ready(function () {
        $('#wysiwyg').wysiwyg()
    });   
</script>

<form id="form" action="example/foo" method="post">
    <textarea id="wysiwyg" name="question" class="required" rows="5" cols="10"> </textarea>
</form>

This is my code in which I am using an HTML editor. I put require validation and it works fine, but if I put only some spaces and submit my form jQuery assumes it is valid. On the other hand in the rest of my project jQuery is behaving normally.

How can I solve this?

4

2 回答 2

0

如果我的问题正确,您正在尝试验证所需属性的文本框,请尝试添加规则,例如

$("#wysiwyg").rules("add", { required: true,
messages: {
required: "This feild is required",
});

并尝试使用以下方法进行验证:

$("#commentForm").validate();
于 2012-05-18T07:03:44.100 回答
0

尝试这个

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" > </script>
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>
    <script>
    $(document).ready(function(){
            $('#form').validate();
    })
</script>
        <form id="form" action="example/foo" method="post">
    <textarea id="wysiwyg" name="question" class="required" rows="5" cols="10"></textarea>
    <input type="submit" value="sub">
于 2012-05-18T07:14:27.710 回答