jQuery用のValidateプラグインを使用してクライアントの検証を実装していますが、TinyMCEエディタコンポーネントを使用するフォームフィールドが不足しています。これにより、実際の編集領域のiframe
とtextarea
要素を含むフォームフィールドのタグの下に、非常に複雑なコントロールツリーがレンダリングされます。私は直接textarea
アクセスすることはできませんので、私は以下のように、.validate()
を呼び出す前に、「必要」属性を追加します。私も空wpsm_body
でフォームを送信する際TinyMCEエディタでjQuery Validateプラグインを使用する
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."
}
});
});
はしかし、私はクライアントの検証エラーを取得していません。
バックグラウンドはWordPressプラグインの中にあり、TinyMCEはwp_editor
関数でレンダリングされますが、これはあまりにも大きな違いがあるとは思えません。
投稿日:これはまったく役に立たないと思われますが、ここではHTMLがブラウザに表示されます。これに続くTinyMCEによって生成されたHTMLは400行で、関連性はありません。
<form id="wpsm-send-mail" action="theform.php" method="POST" enctype="multipart/form-data">
<div id="wp-wpsm_body-wrap" class="wp-editor-wrap tmce-active">
<link rel='stylesheet' id='editor-buttons-css' href='http://localhost/wordpress/wp-includes/css/editor-buttons.dev.css?ver=20111114'
type='text/css' media='all' />
<div id="wp-wpsm_body-editor-tools" class="wp-editor-tools">
<a id="wpsm_body-html" class="hide-if-no-js wp-switch-editor switch-html" onclick="switchEditors.switchto(this);">
HTML</a> <a id="wpsm_body-tmce" class="hide-if-no-js wp-switch-editor switch-tmce"
onclick="switchEditors.switchto(this);">Visual</a>
<div id="wp-wpsm_body-media-buttons" class="hide-if-no-js wp-media-buttons">
<a href="http://localhost/wordpress/wp-admin/media-upload.php?post_id=0&TB_iframe=1"
class="thickbox add_media" id="wpsm_body-add_media" title="Add Media" onclick="return false;">
Upload/Insert
<img src="http://localhost/wordpress/wp-admin/images/media-button.png?ver=20111005"
width="15" height="15" /></a></div>
</div>
<div id="wp-wpsm_body-editor-container" class="wp-editor-container">
<textarea class="wp-editor-area" rows="20" cols="40" name="wpsm_body" id="wpsm_body"></textarea></div>
</div>
</form>
ここでの唯一の関連する項目
はform
と
textarea
、及びその
id
属性です。
一部のHTMLがいいだろうに検証するためのコードである – ori
@ori、私の編集を参照してください。 HTMLを追加することが可能であることを追加しました。 – ProfK