开发者

how to access to textarea of jquery wysiwyg plugin?

开发者 https://www.devze.com 2022-12-18 21:45 出处:网络
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

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-equ开发者_如何学Civ="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');


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 ...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号