Solved

How do I validate openWYSIWYG in Javascript

Posted on 2009-07-14
7
603 Views
Last Modified: 2012-05-07
How do I validate openWYSIWYG in Javascript
<textarea id="txtDefinition"></textarea>
    <script language="JavaScript">
  generate_wysiwyg('txtDefinition');
</script> 
 
 
 
<SCRIPT LANGUAGE=javascript>
<!--
	function Add()
	{
		var textarea = frmAddGlossary.getElementById('txtDefinition').value; 
		if ((frmAddGlossary.txtTerm.value == '') || (textarea == '' ))
		{
			alert( 'You must enter both a Term and Definition.' );
			return;
		}
		frmAddGlossary.action = 'add_glossary_script.asp';
		frmAddGlossary.submit();
	}
//-->
</SCRIPT>

Open in new window

0
Comment
Question by:janp247
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 24856558
Hi janp247,
what is the rendered HTML code for the editor that you're using? Possible post the HTML design/other code snippet?

Try change this line:
var textarea = frmAddGlossary.getElementById('txtDefinition').value;
To
var textarea = document.getElementById('txtDefinition').value;
               
0
 

Author Comment

by:janp247
ID: 24856782
Hi x com,
Hereby the rest of the HTML code.
When I use document instead of the name of the form(frmAddGlossary), it does not see the text in the textarea.

Thanks for your assistance.
<FORM method="post" id="frmAddGlossary" name="frmAddGlossary">
   
<INPUT class="inputbox" id="txtTerm" maxLength="60" onBlur="upperCase()" value="<% If Not IsEmpty(vEdit) Then Response.Write Trim(vEdit(1,0)) %>" name="txtTerm" size="100">
  
<br>    
 
<textarea id="txtDefinition"></textarea>
<script language="JavaScript">
  generate_wysiwyg('txtDefinition');
</script> 
 
<br>
    
<INPUT class="inputsubmit" type="button" id="txtAdd" name="txtAdd" value="ADD TO GLOSSARY" alt="Add" onClick="Add()">
 
</FORM>
 
<SCRIPT LANGUAGE=javascript>
<!--
	function Add()
	{
		var textarea = document.getElementById('txtDefinition').value; 
		if ((frmAddGlossary.txtTerm.value == '') || (textarea == '' ))
		{
			alert( 'You must enter both a Term and Definition.' );
			return;
		}
		frmAddGlossary.action = 'add_glossary_script.asp';
		frmAddGlossary.submit();
	}
//-->
</SCRIPT>

Open in new window

0
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 500 total points
ID: 24857601
In this case, you should use its innerHTML property instead.
eg:
var textarea = document.getElementById('txtDefinition').innerHTML;
               
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:janp247
ID: 24858124
I am not getting any errors but it still does not see the text in the textarea to validate if empty or not.

0
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 24866009
Might to post the code snippet regarding the used library?
0
 
LVL 16

Expert Comment

by:CWS (haripriya)
ID: 37304485
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question