Link to home
Start Free TrialLog in
Avatar of janp247
janp247

asked on

How do I validate openWYSIWYG in Javascript

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

Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

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;
               
Avatar of janp247
janp247

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of janp247

ASKER

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

Might to post the code snippet regarding the used library?
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.