views:

293

answers:

2

I am using the open source Javascript WYSIWYG from OpenWebWare and Asp.Net RequiredFieldValidator on the TextBox which I am calling the WYSIWYG for. Everything works fine, but the first time I try to submit the form, I get the server-side RFV ErrorMessage "Required", but if I submit a second time, it goes through.

Am I missing something? I would like to have the client-side validation... how can I get the text to register as not empty?

Thank you.

+1  A: 

the textarea HTML tag is one of the most unpleasent tags to work with and I'm not 100% sure if the client-side validator will support it, regardless of whether it's a WYSIWYG or not.

I think you'd be best off using a CustomValidator and writing the JavaScript which does the checking manually.

Alternatively you can debug though the JavaScript which is used with FireBug or VS 2008.

Slace
+3  A: 

I think the reason for this behavior is that validation code runs earlier than the code that updates underlying TextBox from value of WYSIWYG. So the first time you get the error, then the field is updated and the second time you don't get it. Try removing all the content the second time and I bet you wont get validation error (since the value for validator at the moment is what you actually submitted the first time).

The solution would be to find a JavaScript API call for your WYSIWYG which would force the update of the underlying text box field and call it onclick (client-side) of your submit button or whatever you use for that.

Alan Mendelevich
Infragistics has some controls that are like this as well, they have underlying (read: hidden) form fields that hold the actual data, and you have to be aware of that if you are doing any significant custom JavaScript with them. I am certain this is the same problem, as Alan indicates.
Jason Bunting