SBM JavaScript Library Guide → Reference → Event Methods → AddFocusCallback
Adds a callback that is invoked when a field or control is focused or blurred.
Name | Type | Description |
---|---|---|
objname | String | The name of the field or control to find. |
callback | Function | The function to be invoked when the field or control is focused or blurred. |
focus | Boolean | Whether to invoke the callback when the field or control is focused or blurred. |
Result | Value |
---|---|
(none) | |
This example registers a named function to be called when a field is focused or blurred:
function customFocusCallback() { if ( IsFieldEmpty( "Description" ) ) { ShowErrorDiv( true, "A description is required" ); } else { ShowErrorDiv( false ); } } AddFocusCallback( "Description", customFocusCallback, false );
Callbacks are invoked in the order in which they are added. This callback can be used to perform validation or other data verification. If you want to display a field validation error, call MakeFieldInvalid from this callback so that any required or invalid field errors are automatically processed.
This method can be used with all field types and all input controls. For Multi-Selection, Multi-Relational, Multi-User, and Multi-Group fields, with the "Allow searching" field style, the focus or blur must occur on the right-hand side of the list box.
Copyright © 2007–2018 Serena Software, Inc., a Micro Focus company. All rights reserved.