Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
javascript
javascript

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;
}

...