Solved

How do I validate openWYSIWYG in Javascript

Posted on 2009-07-14
7
601 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Json Schema 8 32
jQuery force form POST 7 44
How  can  I extract  Id  from a  URL  using  Javascript? 12 29
Why is initialize not a function? 8 18
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

808 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