Many XMod controls allow you to attach Javascript to them that will execute when a certain client-side event fires. Which events are available depends on the underlying form control. Some of the available events are listed below. There may be more or less events available to you depending on the control and the browser being used to view the form. Refer to a Javascript book or documentation for more information.
onblur: The script will execute when the control loses its focus
onfocus: The script will execute when the control receives focus.
onchange: The script will execute when the contents of the control changes. This is especially useful for controls such as the drop-down list control. When the user selects a different item in the control, this event will fire.
onclick: The script will execute when the user uses the mouse to click the control. This is useful when used with XMod's <commandbutton> or with the <addbutton> and <updatebutton> controls. You can use the onclick event to perform validation or calculations. If your javascript returns false then the event will be canceled. This make is possible to prevent a form from being submitted when used with <addbutton> and <updatebutton>. Note: this shouldn't be relied on as a fool-proof method of validation because the user could have Javascript disabled in his/her browser.
onkeypress: The script will execute when the user presses a key on the keyboard.
<input ref="FirstName" onfocus="alert('Enter your first name');">
<label>First Name</label>
</input>
If the validateForm() function returns false, the add button will cancel
it's processing. This will keep the record from being added until the
form values are valid (i.e. when validateForm() returns true)
<addbutton text="Add Item" display="button" onclick="validateForm();"/>