tags:

views:

283

answers:

3

Hi, I need to execute an entire javascript function.

Found what i was doing wrong:

var edit = igedit_getById("FG2100RefNo");
var editText = edit.getText();
alert(!isNaN(editText));

But this only checks & displays a message box.

I need to execute the below javascript:

<SCRIPT language=Javascript>
  <!--
  function isNumberKey(evt)
  {
     var charCode = (evt.which) ? evt.which : event.keyCode
     if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

     return true;
  }
  //-->

onkeypress="return isNumberKey(event)"

How do i do this with the webtextedit:

var edit = igedit_getById("FG2100RefNo");
var editText = edit.getText();
function isNumberKey(evt)
{
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) return false;
    return true;
}
return isNumberKey(editText)

I only have the onkey event property value to insert the code!

Please Assist

A: 

Your onkeypress="return isNumberKey(event)" function is sufficient to force user type only numerics.

Sachin Gaur
A: 

Hi, Thank You for the assist.

But unfortunately struggling.

I have an onkeypress event where i can insert the code.

var edit = igedit_getById("FG2100RefNo");var editText = edit.getText();alert(!isNaN(editText));

Now this pops a message when true, but the above fuinction does not allow for any char to be typed.

I have no place to specify the javascript function and the call from the event code.

I tried: 1. return isNumberKey(event) 2. var edit = igedit_getById("FG2100RefNo");var editText = edit.getText();return isNumberKey(editText)

I think the problem is that it does not see the javascript function in order for to use.

Please Assist, Regards

A: 

You can provide the client function name to the control's ClientSideEvents.KeyPress property from the server-side.

C#:

FG2100RefNo.ClientSideEvents.KeyPress = "isNumberKey";

you'll have to update the definition of isNumberKey to accept the parameters provided and use the control's method of canceling the action.

ClientSideEvents reference: http://help.infragistics.com/Help/NetAdvantage/ASPNET/2009.1/CLR3.5/html/Infragistics35.WebUI.WebDataInput.v9.1~Infragistics.WebUI.WebDataInput.WebTextEdit~ClientSideEvents.html

lincolnk