Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I validate openWYSIWYG in Javascript

Posted on 2009-07-14
7
Medium Priority
?
623 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 2000 total points
ID: 24857601
In this case, you should use its innerHTML property instead.
eg:
var textarea = document.getElementById('txtDefinition').innerHTML;
               
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Industry Leaders: 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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

604 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