onfocus - Focus On Script

Activates an event handler when a control gains focus.

Category

events

Syntax

<xp:eventHandler event="onfocus" attributes>content</xp:eventHandler>

Usage

For detailed event handler syntax, see eventHandler - Event Handler (property).

Examples

This input box has both client and server handlers for the onfocus event. The client handler runs first. If the confirm statement returns true (the user responds OK), the server handler runs.
<xp:inputText id="inputText2">
	<xp:eventHandler event="onfocus" submit="true"
		refreshMode="complete">
		<xp:this.action>
			<![CDATA[#{javascript:requestScope.status = "Input box on focus"}]]>
		</xp:this.action>
		<xp:this.script>
			<![CDATA[return confirm("Do you want to submit?")]]>
		</xp:this.script>
	</xp:eventHandler>
</xp:inputText>