Solved

How do I validate openWYSIWYG in Javascript

Posted on 2009-07-14
7
595 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
Comment Utility
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
Comment Utility
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
Comment Utility
In this case, you should use its innerHTML property instead.
eg:
var textarea = document.getElementById('txtDefinition').innerHTML;
               
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:janp247
Comment Utility
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
Comment Utility
Might to post the code snippet regarding the used library?
0
 
LVL 16

Expert Comment

by:CWS (haripriya)
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now