First, I have not tried earlier versions. However, I have been trying to work with 2.0b2 and while the editor looks great on all platforms, it is little more then a pretty toy if you cannot get the content that the user has edited!
Ideally, I would like to first validate the content using javascript in the browser window (easy example, to make certain some text was entered), then retrieve the HTML text entered when the form is submitted.
So far, I have searched this message board in detail, and still am unable to even access the content to validate it before I submit it. If anyone has been able to get this to work, please assist. From what I've seen a lot of people are having problems with this, and things that worked back in 1.X are failing in 2.X.
This is what I'm trying to do. Validate the form when the submit button is pressed. The form populates and displays well. The main issue I am having is upon submission. Included is the relevant javascript for submission, pretty elementary, followed by clippings from the form embedded in the table. Has anyone been able to get this to work? Here is my sample:
<script type="text/javascript">
function SubmitForm() {
if (ValidateForm() == true ) {
document.d2form.submit();
}
}
function ValidateForm() {
<%-- if window.frames[0].objContent.DOM.body.innerText.length == 0 )--%>
<%-- alert( window.frames[0]. richMessage.DOM.body.innerHTML ) ;--%>
<%-- if ( document.d2form.richMessage.value == "" ) --%>
<%--if (parent.document.getElementsByName("richMessage")[0].value == "")--%>
<%-- {--%>
<%-- alert( 'The message body is required') ; return false;--%>
<%-- }--%>
<%-- alert( parent.document.getElementsByName("richMessage")[0].value) ;--%>
<%-- return false ;--%>
if (isBlank(oFCKeditor.getValue(), "Message Body:"))
{
alert( 'The message body is required') ; return false;
}
alert( parent.document.getElementsByName("richMessage")[0].value) ;
return false ;
<%-- return parent.document.getElementsByName(this.InstanceName)[0].value;--%>
<%-- if (document.d2form.richMessage=="") return false;--%>
return true;
}
</script>
(some HTML code omitted.. skipping to the form... note some text has been cut out to demonstrate what I've been working on...)
<form action="<html:rewrite page="/addpostprocess.do" />" method="post" name="d2form">
<input type="hidden" name="forum" value="1">
<input type="hidden" name="parent" value="0">
<table class="tborder" width="95%" cellspacing="1" cellpadding="3" align="center">
<tr class="trow1">
<td width="170" nowrap><span class="requiredfield">*</span> Mesage Topic:</td>
<td><input type="text" name="PostTopic" value="" size="70" class="bginput" tabindex="1" onKeyUp="initTyper(this);"></td>
</tr>
<tr class="trow1">
<td>
<script type="text/javascript">
var oFCKeditor = new FCKeditor( 'richMessage' ) ;
oFCKeditor.BasePath = '/d20forum/FCKeditor/' ;
oFCKeditor.Value='<%=postBody%>';
oFCKeditor.Height=400;
oFCKeditor.ToolbarSet="D20Forum";
oFCKeditor.Create() ;
</script>
</td>
</tr>
<tr class="trowfinal">
<td colspan="2" align="center">
<input type="button" name="submitbutton" value="addpost" onclick="javascript:SubmitForm()" class="mainoption">
<input type="reset" value="reset" class="liteoption">
</td>
</tr>
</table>
</form>
Ideally, I would like to first validate the content using javascript in the browser window (easy example, to make certain some text was entered), then retrieve the HTML text entered when the form is submitted.
So far, I have searched this message board in detail, and still am unable to even access the content to validate it before I submit it. If anyone has been able to get this to work, please assist. From what I've seen a lot of people are having problems with this, and things that worked back in 1.X are failing in 2.X.
This is what I'm trying to do. Validate the form when the submit button is pressed. The form populates and displays well. The main issue I am having is upon submission. Included is the relevant javascript for submission, pretty elementary, followed by clippings from the form embedded in the table. Has anyone been able to get this to work? Here is my sample:
<script type="text/javascript">
function SubmitForm() {
if (ValidateForm() == true ) {
document.d2form.submit();
}
}
function ValidateForm() {
<%-- if window.frames[0].objContent.DOM.body.innerText.length == 0 )--%>
<%-- alert( window.frames[0]. richMessage.DOM.body.innerHTML ) ;--%>
<%-- if ( document.d2form.richMessage.value == "" ) --%>
<%--if (parent.document.getElementsByName("richMessage")[0].value == "")--%>
<%-- {--%>
<%-- alert( 'The message body is required') ; return false;--%>
<%-- }--%>
<%-- alert( parent.document.getElementsByName("richMessage")[0].value) ;--%>
<%-- return false ;--%>
if (isBlank(oFCKeditor.getValue(), "Message Body:"))
{
alert( 'The message body is required') ; return false;
}
alert( parent.document.getElementsByName("richMessage")[0].value) ;
return false ;
<%-- return parent.document.getElementsByName(this.InstanceName)[0].value;--%>
<%-- if (document.d2form.richMessage=="") return false;--%>
return true;
}
</script>
(some HTML code omitted.. skipping to the form... note some text has been cut out to demonstrate what I've been working on...)
<form action="<html:rewrite page="/addpostprocess.do" />" method="post" name="d2form">
<input type="hidden" name="forum" value="1">
<input type="hidden" name="parent" value="0">
<table class="tborder" width="95%" cellspacing="1" cellpadding="3" align="center">
<tr class="trow1">
<td width="170" nowrap><span class="requiredfield">*</span> Mesage Topic:</td>
<td><input type="text" name="PostTopic" value="" size="70" class="bginput" tabindex="1" onKeyUp="initTyper(this);"></td>
</tr>
<tr class="trow1">
<td>
<script type="text/javascript">
var oFCKeditor = new FCKeditor( 'richMessage' ) ;
oFCKeditor.BasePath = '/d20forum/FCKeditor/' ;
oFCKeditor.Value='<%=postBody%>';
oFCKeditor.Height=400;
oFCKeditor.ToolbarSet="D20Forum";
oFCKeditor.Create() ;
</script>
</td>
</tr>
<tr class="trowfinal">
<td colspan="2" align="center">
<input type="button" name="submitbutton" value="addpost" onclick="javascript:SubmitForm()" class="mainoption">
<input type="reset" value="reset" class="liteoption">
</td>
</tr>
</table>
</form>
RE: Can anyone get the HTML value from 2.0b2?
function getFCKContent() {
var api=FCKeditorAPI.GetInstance("richMessage");
return api.GetHTML();
}
RE: Can anyone get the HTML value from 2.0b2?
RE: Can anyone get the HTML value from 2.0b2?
RE: Can anyone get the HTML value from 2.0b2?
all imports and other stuff?
please I'm stuck...
RE: Can anyone get the HTML value from 2.0b2?
function getFCKContent(field) {
var api=FCKeditorAPI.GetInstance(field);
return api.GetHTML();
}
function isRichMessageBlank(field, strBodyHeader) {
rawtext = getFCKContent(field);
rawtext = rawtext.replace(/type=\"_moz\"/gi, "");
rawtext = rawtext.replace(/ /gi, "");
rawtext = rawtext.replace(/<br\/?>/gi, "");
rawtext = rawtext.replace(/<\/?p>/gi, "");
myHtml = trim(rawtext);
if ( myHtml == "") {
alert("\"" + strBodyHeader + "\" is a required field.");
return true;
}
return false;
}
function ValidateForm() {
if (isBlank(document.myform.PostTopic, "Topic:")) return false;
if (isRichMessageBlank("richMessage", "Message Body:")) return false;
<%-- rawtext = getFCKContent("richMessage");--%>
<%-- rawtext = rawtext.replace(/_moz_editor_bogus_node=\"TRUE\"/gi, "");--%>
<%-- rawtext = rawtext.replace(/type=\"_moz\"/gi, "");--%>
<%-- alert(rawtext);--%>
return true;
}