|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Displaying the number of characters typed in FCKeditorHello all,
Is there a way I can count the number of characters typed on the FCKeditor so that I can restrict any input from exceeding the maximum characters allowed? On the form containing the FCKeditor, I would also like to display the number of characters being typed so that the users know how many characters are remaining. Thank you ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/Javascript/message.cfm/messageid:3105 Subscription: http://www.houseoffusion.com/groups/Javascript/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.33 |
|
|
Re: Displaying the number of characters typed in FCKeditorHi Pragya,
Quoted from the HTML samples provided with FCKeditor: [START OF CODE] function getLength(){ // This functions shows that you can interact directly with the editor area // DOM. In this way you have the freedom to do anything you want with it. // Get the editor instance that we want to interact with. var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ; // Get the Editor Area DOM (Document object). var oDOM = oEditor.EditorDocument ; var iLength ; // The are two diffent ways to get the text (without HTML markups). // It is browser specific. if ( document.all ) // If Internet Explorer. { iLength = oDOM.body.innerText.length ; } else // If Gecko. { var r = oDOM.createRange() ; r.selectNodeContents( oDOM.body ) ; iLength = r.toString().length ; } alert( 'Actual text length (without HTML markups): ' + iLength + ' characters' ) ; } [END OF CODE] So this is the code you will need to find out the length of the text. As for doing it as the result of user interaction ie. to update it as the user types, I couldn't find anything useful on the SourceForge forums for FCKeditor, but there must be some way...can anyone else help? We need some kind of 'onChange' handler. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/Javascript/message.cfm/messageid:3125 Subscription: http://www.houseoffusion.com/groups/Javascript/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.33 |
|
|
Re: Displaying the number of characters typed in FCKeditor//FCK Editor character validation
function FCKeditor_OnComplete( editorInstance ) { if(editorInstance.Name=="FCKeditor1") { editorInstance.Events.AttachEvent( 'OnSelectionChange', DoSomething ) ; editorInstance.Events.AttachEvent( 'OnPaste', DoSomething ) ; } } var counter = 0 ; var excee = ""; var exvee=""; function DoSomething( editorInstance ) { // This is a sample function that shows in the title bar the number of times // the "OnSelectionChange" event is called. //window.document.title = editorInstance.Name + ' : ' + ( ++counter ) ; var cnt=0; if(document.all) { cnt = editorInstance.EditorDocument.body.innerText.length; excee = editorInstance.EditorDocument.body.innerHTML; } else { cnt = editorInstance.EditorDocument.body.textContent.length; excee = editorInstance.EditorDocument.body.innerHTML; } if(cnt > 150) { editorInstance.EditorDocument.body.innerHTML = exvee; return false; } else { exvee = excee; document.opportunity.tbCnt.value = 150 - cnt; return true; } //alert(editorInstance.EditorDocument.body.innerText); }
|
| Free embeddable forum powered by Nabble | Forum Help |