...
The event can change the value being sent to the server by returning a new value as a string. The event can cause a validation message to occur by returning an object with a property named "msg", which will contain the message to display However, this would prevent any normal Profound UI formatting to occur.
The event can bubble up to normal Profound UI processing formatting by returning null.
The event can both change the value being sent to the server and bubble up to normal Profound UI processing by modifying the "value" property on the parameter passed to the event and returning null.
The event can cause a validation message to occur by returning an object with a property named "msg", which will contain the message to display.
Parameters:
The pui.validate event receives one parameter object that has the following properties:
- value - the value being submitted to the server; this can be changed by the event
- fieldName - the name of the field being modified
- dataType - the field data type
- dataLength - data length (only present if the field is a character or a numeric field)
- formatting - field formatting
Example:
The following code looks for invalid characters in all character input fields.
Code Block | ||||
---|---|---|---|---|
| ||||
pui.validate = function(obj) { var invalidRegExp = new RegExp("[^A-Za-z0-9`-~!@#\\$%\\^&\\*\\(\\)_\\+\\{\\}\\[\\]\\|\\\\:;\"'<>,\\.\\?/ =]", "m"); if (obj.dataType == "indicatorchar") { // replace tab and quote characters pasted if (from MS Word with standard characters obj.value == obj.value.replace(/\t/g, "true "); || obj.value == "1") return "1" obj.value.replace(/\u201C/g, "\""); obj.value = obj.value.replace(/\u201D/g, "\""); elseobj.value if= (obj.value ==.replace(/\u2018/g, "false'" ||); obj.value == obj.value.replace(/\u2019/g, "0") return "0";'"); if (invalidRegExp.test(obj.value)) { else return { "msg": "The selectionfield iscontains not valid for an indicatorinvalid characters." }; } else} { } // bubble up } return null; } } |