I am implementing client validation using the Validate plugin for jQuery, and coming short with a form field that uses the TinyMCE editor component. This renders an incredibly complex control tree under the containing tag for my form field, including an
iframe for the actual editing area, and a
textarea element. I cannot access the
textarea directly, so I add the
required attribute before calling
.validate()
, like below:
jQuery(function() {
jQuery("#wpsm_body").addClass("required");
jQuery("#wpsm-send-mail")
.validate(
{
errorContainer : "#wpsm-top-error-container, #wpsm-bottom-error-container",
errorLabelContainer : "#wpsm-top-error-container ul",
wrapper : "li",
messages : {
wpsm_from : "The message has no 'From' address. The administrator can set a default for this on the SuperMail 'Settings' page.",
wpsm_subject : "The message has no subject.",
wpsm_body : "The message has no body.",
wpsm_text : "The message has no body."
}
});
});
However, I get no client validation error when I submit the form even with an empty
wpsm_body
.
For background, this is inside a WordPress plugin, and TinyMCE is rendered by the
wp_editor
function, although I doubt this makes too much difference.