views:

151

answers:

1

I'm using RSV to validate form element, and tinymce to convert textarea to editor.

The textarea is included to be checked by rsv validator using 'required', since the textarea is being converted to tinymce editor. Theres a problem on the validation, even i entered the value in the editor the validator says that textarea is a null.

How can i validate the textarea using RSV?

any ideas?

Thanks in advance.

+1  A: 

I'm not familiar neither with jQuery RSV nor the jQuery TinyMCE plugin and thus don't know how RSV tries to validate this.

But I hope you are at least aware that TinyMCE makes heavy modifications to the actual DOM to do its job. And that the textarea you see and are writing in, has nothing to do with the original <textarea></textarea> you called the plugin on.

That is because the actual editing area is in an dynamically created iframe. Probably that explains why jQuery RSV can't validate the original textarea which probably is hidden and still empty as the real editing area is in an iframe. But..

Assuming you have similar code to this in somewhere in your project

<textarea id="content" name="content" style="width:100%"></textarea>
$('#content').tinymce({
...
})

Hopefully RSV has some callbacks which allow you to do something before the validations is actually done. If that is the case you need to hook into such a callback and make the call

$('#content').html()

Which should (handled by the jQuery TinyMCE plugin) give you the actual content typed in TinyMCE.

Now I suggest that you actually insert two textareas in your form. One hidden which is the one you validate via RSV. Now you only need to place the output of the above call in the hidden textarea and RSV should validate it just fine

jitter
Thank you for the suggestion. jquery RSV don't have before submit callback, however i put onclick on the submit button: onlick="return putValue();" and it went well for me. Anyways its a bright ideas, hope to help others too.
Trez