pui.inputfilter



The pui.inputfilter function, if defined, fires for each field that is modified on a Genie/5250 or Rich Display File screen. The function has the opportunity to modify the original user input before it is submitted to the server. This can be useful for filtering out undesirable characters, such as when the user copies/pastes data into the screen from another application.

Parameters:

The pui.inputfilter function receives the following parameters:

  • value - a string containing the original user input value.

  • fieldInfo - information about the field. The format of this parameter is different for Rich Display File screens vs. Genie/5250 screens, and is subject to addition of properties in the future. It's recommended to explore the parameter with a JavaScript debugger to see what the available properties are.

  • context - a string set to either "genie" for Genie/5250 screen, or "dspf" for Rich Display File screen.

If the pui.inputfilter function returns a string, the return value will be used in place of the original value. Any other type of return value (or if no value is returned) will result in the original field value being used.

If an unhandled exception occurs in the function, the original user input will be used and the exception will be logged to the browser's console. 

Example:

The following code replaces tabs with a space, and "smart quotes" (such as copied/pasted from MS Office apps) with the normal single/double quote character.

pui.inputfilter = function(value, fieldInfo, context) { return value.replace(/\t/g, " "). replace(/\u201C/g, "\""). replace(/\u201D/g, "\""). replace(/\u2018/g, "'"). replace(/\u2019/g, "'"); }