views:

221

answers:

1

Hi All,

I have to attach OnKeyPress event to the SharePoint multiline column with text type as "Enhance Rich Text". Following is the jscript code that I am using

 <script>

    var ele=document.getElementById(inpID);

     if(ele!=null){
     ele.onkeypress=function(){calLen(this);};
    }

function calLen(obj)
{

  if(obj.value.length>=5){
   alert('Cannot exceed character limit 5');
      obj.value=obj.value.substring(0,5);
}

</script>

But the event is not get attached.

The things are working fine with SharePoint Multiline TextBox with Text Type as "Plain Text".

Can some one help me to solve this issue...?

Thanks in Advance..

Sachin

+1  A: 

Enhanced Rich Text fields are not rendered as any sort of standard FORM control (like, for instance, a simple TEXTAREA). They are complex controls comprised of, among other things, an IFRAME that can display your HTML content preview.

I recommend using Internet Explorer's Developer Toolbar (or even better, Firebug for Mozilla Firefox) to drill in to the E.R.T. "control" and figure out what subcomponents you could bind to.

Also, it's entirely possible that some events, like onkeypress, are already being handled internally to the E.R.T. and thus will never bubble up so that you can handle them.

If you're using a replacement component for your E.R.T. (esp. Telerik's RADEditor), there may be some custom events that have been implemented and to which you could bind to.

CBono
Hi CBonoThanks for your quick reply.
Sachin