1

Has anybody successfully integrated Redactor editor with jQuery validation?

<textarea class="text-input textarea" rows="25" id="page_content" name="page_content"></textarea>

$("#add_cms").validate({
    rules: {
        page_content: "required"
        },
    messages: {
        page_content: "Content can't be empty!"
        }
});

@Sparky, I was struggling with it for a few hours, tried additional-methods too. But the method wasn't even getting invoked. I got frustrated and removed all those code. It was at that point that I asked the question here.

It seems that Redactor is rendering the textarea as display:none; so the jQuery validate isn't getting triggered.

4
  • That's a "yes/no" question. If you're really looking for a solution with code, then show your own attempt first. Commented Oct 28, 2013 at 14:35
  • @Sparky Did you really have to take away 4 of my only 6 reputation points? I am pretty new here, give me a break. Commented Oct 30, 2013 at 11:10
  • I have no power to do any such thing. Also, comments is not the appropriate place to discuss or complain about your rep. Commented Oct 30, 2013 at 13:54
  • Have you tried using sync in the blurCallback? I think that will put the text into the textarea. Commented Oct 30, 2013 at 23:21

1 Answer 1

2

Quote OP:

It seems that Redactor is rendering the textarea as display:none; so the jQuery validate isn't getting triggered.

If that's all it is, you can simply enable that feature of the plugin.

By default, jQuery Validate will ignore all hidden fields. This can be reversed by setting the ignore option to [].

$("#add_cms").validate({
    ignore: [],    // <-- allows validation of all hidden fields
    rules: {
        page_content: "required"
    },
    messages: {
        page_content: "Content can't be empty!"
    }
});

See this answer: https://stackoverflow.com/a/8565769/594235

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.