CodeCharge Studio

On Key Press

Applies to

Text Area, Text Box

Description

This event occurs when the user presses an alphanumeric key. It can be used to change the value of other controls.

Examples

The following example shows how the On Key Press event can be used to set the value of a Text Box called TextBox2 whenever a new value is entered in another Text Box called TextBox1.
<script language="JavaScript">
function page_NewRecord2_TextBox1_OnKeyPress()
{
  var result;
  //Custom Code 
  var maxlength = document.NewRecord2.TextBox1.value.length + 1;
  document.NewRecord2.TextBox2.value = maxlength;
  //End Custom Code
  return true;
}

function bind_events() {
  check_and_bind('document.NewRecord2.TextBox1','onkeypress',page_NewRecord2_TextBox1_OnKeyPress);
  forms_onload();
}

window.onload = bind_events; 
</script>


On-line, printable versions and updates