...
- 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 == "char") {
// replace tab and quote characters pasted from MS Word with standard characters
obj.value = obj.value.replace(/\t/g, " ");
obj.value = obj.value.replace(/\u201C/g, "\"");
obj.value = obj.value.replace(/\u201D/g, "\"");
obj.value = obj.value.replace(/\u2018/g, "'");
obj.value = obj.value.replace(/\u2019/g, "'");
if (invalidRegExp.test(obj.value)) {
return {
"msg": "The field contains invalid characters."
}
}
}
return null;
}
|
...