Solved

How do I validate openWYSIWYG in Javascript

Posted on 2009-07-14
7
600 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
  • 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
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…

821 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