views:

188

answers:

1

I'm using YUI(Yahoo UI) rich text editor control in my MVC view page. I need to do a jquery required field validation. It shows error message when submit without any value in that field but it stays after typing the value in the text editor.

Please help me if anyone has tried it before or if you have any other javascript validation logic for YUI rich text editor?

Thanks.

+1  A: 

I haven't used that editor before. But the problem is that the editor doesn't use the text area until you submit the form. Therefore there is no text in the text area when the validation takes place. Instead of setting required: true in you jquery validation you can supply a function. Like this:

required: function() { 
    //Get text from editor and validate it.
}

As I haven't used that editor before I can't tell you how to get the text. But if you google it I'm sure you will find the answer. Maybe someone have created a plugin (I know there is one for fckeditor) that will help you with this so you don't have to validate it manually.

Mattias Jakobsson