mike99c
asked on
Validating text content entry (InnovaStudio WYSIWYG Editor)
I've got a form with a texteditor (innova) in it. I'd like to validate using Javascript that some text has been entered. I get a run time error when I try
and read values from the form from within the JS validate routine.
The error is:
A Runtime Error has occurred.
Do you wish to Debug?
Line: 8
Error: 'TheContent.value' is null or not an object
The code is as follows, you need the innova text edit script source, to get the editor to work.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script SRC='/Editor/scripts/innov aeditor.js ' TYPE="text/javascript"></s cript>
<script TYPE="text/javascript">
function ValidateForm(myForm) {
if (myForm.TheContent.value== "") {
alert("Please enter text information");
return false;
} else {
return true;
}
}
</SCRIPT>
<head>
</head>
<body>
<form action="" method="get" onsubmit="return ValidateForm(this)">
<table width="75%" border="1">
<tr>
<td>Text Info</td>
<td><textarea id="TheContent" name="TheContent" rows=10 cols=48></textarea>
<script>
var oEdit1 = new InnovaEditor("oEdit1");
/************************* ********** ********** ******
ENABLE ASSET MANAGER ADD-ON
************************** ********** ********** *****/
oEdit1.cmdAssetManager = "modalDialogShow('/Editor/ assetmanag er/assetma nager.asp' ,640,465)" ; //Command to open the Asset Manager add-on.
oEdit1.css="/sitestyles.cs s"
oEdit1.arrStyle = [["BODY",true,"","padding: 20px;backg round-colo r: white;"]];
oEdit1.useDIV=false
oEdit1.features=["ForeColo r","|","Nu mbering"," Bullets"," |","Indent ","Outdent ","Line"," Paragraph" ,"FontSize ","|","Bol d","Italic ","Underli ne"];
oEdit1.width="100%"
oEdit1.REPLACE("TheContent ");//Speci fy the id of the textarea here
</script></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
and read values from the form from within the JS validate routine.
The error is:
A Runtime Error has occurred.
Do you wish to Debug?
Line: 8
Error: 'TheContent.value' is null or not an object
The code is as follows, you need the innova text edit script source, to get the editor to work.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script SRC='/Editor/scripts/innov
<script TYPE="text/javascript">
function ValidateForm(myForm) {
if (myForm.TheContent.value==
alert("Please enter text information");
return false;
} else {
return true;
}
}
</SCRIPT>
<head>
</head>
<body>
<form action="" method="get" onsubmit="return ValidateForm(this)">
<table width="75%" border="1">
<tr>
<td>Text Info</td>
<td><textarea id="TheContent" name="TheContent" rows=10 cols=48></textarea>
<script>
var oEdit1 = new InnovaEditor("oEdit1");
/*************************
ENABLE ASSET MANAGER ADD-ON
**************************
oEdit1.cmdAssetManager = "modalDialogShow('/Editor/
oEdit1.css="/sitestyles.cs
oEdit1.arrStyle = [["BODY",true,"","padding:
oEdit1.useDIV=false
oEdit1.features=["ForeColo
oEdit1.width="100%"
oEdit1.REPLACE("TheContent
</script></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>> you referenced an object called "myForm" that does not exists in your code
Isn't it passed as a parameter to the function?
Isn't it passed as a parameter to the function?
I do not see any problem with your Javascript code, look like a issue with InnovaEditor(),
I just commented the script line to verify that..
just try following script..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script SRC='/Editor/scripts/innov aeditor.js ' TYPE="text/javascript"></s cript>
<script TYPE="text/javascript">
function ValidateForm(myForm) {
if (myForm.TheContent.value== "") {
alert("Please enter text information");
return false;
} else {
return true;
}
}
</SCRIPT>
<head>
</head>
<body>
<form action="" method="get" onsubmit="return ValidateForm(this)">
<table width="75%" border="1">
<tr>
<td>Text Info</td>
<td><textarea id="TheContent" name="TheContent" rows=10 cols=48></textarea>
<script>
var oEdit1 = new InnovaEditor("oEdit1");
oEdit1.REPLACE("TheContent ");//Speci fy the id of the textarea here
</script></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
I just commented the script line to verify that..
just try following script..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script SRC='/Editor/scripts/innov
<script TYPE="text/javascript">
function ValidateForm(myForm) {
if (myForm.TheContent.value==
alert("Please enter text information");
return false;
} else {
return true;
}
}
</SCRIPT>
<head>
</head>
<body>
<form action="" method="get" onsubmit="return ValidateForm(this)">
<table width="75%" border="1">
<tr>
<td>Text Info</td>
<td><textarea id="TheContent" name="TheContent" rows=10 cols=48></textarea>
<script>
var oEdit1 = new InnovaEditor("oEdit1");
oEdit1.REPLACE("TheContent
</script></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
looks i was tired yes ;)
ASKER
Hi Tim
Spot on, works a treat now, thanks for the swift response!
Cheers
Mike
Spot on, works a treat now, thanks for the swift response!
Cheers
Mike
You got an error because you referenced an object called "myForm" that does not exists in your code. Your form has no id.
This could work too:
function ValidateForm(myForm) {
if (document.forms[0].element
alert("Please enter text information");
return false;
} else {
return true;
}
}