views:

332

answers:

1

hi! i'm using wysiwyg plugin (http://code.google.com/p/jwysiwyg/) for a project and i would get if textarea is empty or not to give to users an alert before submitting the form but this plugin create an iframe and i can't get it.

this is html generated by plugin that replace textarea with id #testo

<p><div class="wysiwyg" style="width: 896px;"> 

    <div style="clear: both;"><!-- --></div>
    <iframe tabindex="0" id="testoIFrame" style="min-height: 130px; width: 888px;" src="javascript:false;" frameborder="0">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body style="margin: 0px; font-family: Arial,Helvetica,sans-serif; font-size: 12px;">

your text here

</body>
</html>

</iframe>

    </div>

    <textarea style="display: none;" id="testo" name="testo" rows="8">
    </textarea></p>

textarea is not displayed. if there's no text in iframe i would add a class to content div with:

$('#testo').addClass('border');

A: 

I believe this would work ..

$('#your_form_id').submit(
  function(){
    $testoTextarea = $('#testo');
    $testoFrame = $('#testoIFrame');
    if ($testoTextare.val() == '')
       {
         $testoFrame.addClass('border');
         return false;
       }
    return true;
  }
);

The thing is that on submit the plugin will have to put the text back to the textarea for it to get passed to the next page..
Also the iframe takes an id that is the original textareas id + 'IFrame' so it is easy to identify it ...

Gaby
don't works, form is submitted also if #testo is empty and class is not added.
antonio
can you show us some more code.. like the actual form, and also let us know if you use some ajax code to submit the form ..
Gaby