SBM JavaScript Library Guide → Reference → Event Methods → AddSubmitCallback
Adds a callback that is invoked before the page is submitted.
Name | Type | Description |
---|---|---|
callback | Function | The function to be invoked before the page is submitted. |
Result | Value |
---|---|
true | Continue processing other submit callbacks. If a function does not return a value, it is assumed to be "true". |
false | Stop processing other submit callbacks and cancel the submit operation. |
This example registers a named function to be called before the page is submitted:
function customSubmitCallback() { // Prevent submit if Description field is empty if ( IsFieldEmpty( "Description" ) ) { ShowErrorDiv( true, "A description is required" ); return false; } else { ShowErrorDiv( false ); return true; } } AddSubmitCallback( customSubmitCallback );
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 and return "true" from this callback so that any required or invalid field errors are automatically processed.
Copyright © 2007–2016 Serena Software, Inc. All rights reserved.