Hello FCK,
Hope somebody can help... I've created a series of FCK editor text areas within a form. When the form is submitted a client side javascript form validation process is started. Of course I found out that you can't validate FCK editor fields in the normal way but rather you need to rely on the API once the editor is loaded.
I've searched the forum and found out that I need to use oEditor.GetXHTML(true):
http://www.fckeditor.net/forums/viewtopic.php?f=6&t=7120&p=18975&hilit=validation#p18975
The only problem is the browser then complains that the API is undefined... digging into this further I've tested whether the API exists via this piece of javascript:
if (typeof(FCKeditorAPI)!=='undefined') { alert("API Not Defined"); } else { alert("All good") }
Re: form validation and FCK
In case you still have the problem mentioned. Try this. On the page hosting the fckeditor add this javascript function.
function FCKeditor_OnComplete(editorInstance)
{
alert( editorInstance.Name );
}
after that you will be able to access the editors contents using the javascript API.
var oEditor = FCKeditorAPI.GetInstance(instancename);
var contents = oEditor.GetXHTML(true);
alert(contents);
Hope this helps.
Re: form validation and FCK
I must be missing exactly where to place the code.
Re: form validation and FCK
SO ,
var oEditor = FCKeditorAPI.GetInstance('keywords');// note keywords is the name of the new FCKeditor and has to be quoted
var contents = oEditor.GetXHTML(true);
the value of contents can then be validated as you normally would in any JS function.
Re: form validation and FCK
if ( typeof ( FCKeditorAPI ) == 'defined' ) { // call if defined ##
var oEditor = FCKeditorAPI.GetInstance('instancename');
var instancename = oEditor.GetXHTML(oEditor.FormatOutput);
}