How to "kill" jump function on collision.

I need to know how to disable the jumping funktion the plaeyr character when collidion with a certain object.

I use JS.

var canJump : boolean = true;

function OnCollisionEnter(other : Collision){
   canJump = false;
}

function Update(){
   if(Input.GetButton("Jump") && canJump){
      //jump
   }
}