views:

140

answers:

1

Hi

I have a Rich Html editor called JhtmlArea and it makes a Iframe over a textarea. I have a validation set on this textarea but since JhtmlArea makes a Iframe it hides the textarea and nothing is every inserted in this.

So my validation will never fire. So how can I validate a iframe with jquery.validate?

http://jhtmlarea.codeplex.com/

A: 

Do you want to validate if the user left the textarea blank? I suppose so.

You have two ways to do IMO. I'm speculating that you're going to have a "submit" button, so in this scenarion:

  • You could copy each key event that goes into the iframe to the textarea, so clicking the submit button is like you were writing directly in the textarea; (beware of performance)
  • Call a method that copies the iframe content to the textarea immediately after you clicked the submit button.

I haven't checked your app source, so I dont know if an iframe is really the best approach.

GmonC
Well I don't know if a iframe is the best approach but these Rich Html editor plugins seem to use them. So it's either live with a iframe or not use these plugins. So your saying on submit copy the stuff first to the text area then sumbit the form?
chobo2
Yes, thats the best approach in this case in my opinion. You should also test this workaround with large chunks of text to see how browsers would behave, to see if a "loading" div is needed, etc.
GmonC
Hmm you think a Max of 600 characters would take a while to copy over from the jhtml to textarea?
chobo2
Browsers have different engines and javascript implementations, I can't say to you how many characters would be slow - you would really need to test it. I don't think you're going to have a single problem in simple everyday use, but it's interesting to put some boundaries in your application like this character limit to prevent some bugs in the future.
GmonC