Pregunta

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.

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top