onkeydown on a input text

I am using the dhtmlx form such as:

{type:"fieldset", inputWidth:310, label:"Contact", list:[
{type: "settings", position: "label-left", labelWidth: 80, inputWidth: 150, labelAlign: "right"},
{ type:"input" , name:"home_phone",   label:"Home Phone",   position:""  },
{ type:"input" , name:"work_phone",   label:"Work Phone",   position:""  },
{ type:"input" , name:"mobile_phone", label:"Mobile Phone", position:""  },
{ type:"input" , name:"email",        label:"Email",        validate: "hasEmail"  }

I would like to attach a onkeydown/onkeyup function to the home_phone field. The function formats the phone.

Normally I would do:

<INPUT NAME="home_phone" SIZE="20" MAXLENGTH="20" value="" onkeydown="javascript:backspacerDOWN(this,event);" onkeyup="javascript:backspacerUP(this,event);">

Is there a way to attach an onkeydown function to an input? It looks like form_1.getInput() is powerful, is this it might be done?

I just figured out the solution:

    form_1.getInput("home_phone").onkeyup=function(){  backspacerUP(this,event);}
    form_1.getInput("home_phone").onkeydown=function(){  backspacerDOWN(this,event);  }

Correct! :slight_smile: