/** *
Description: 校验文本框的最大最小值
* @param min 最小值 * @param max 最大值 */ function checkLength(min, max) { var id = this.event.srcElement.name; var value = nui.get(id).getValue(); var length = 0; for (var i = 0; i < value.length; i++) { if (value.charCodeAt(i) > 255) { length += 3; } else { length++; } } if (max > 0 && length > max) { nui.get(id).setVtype("maxLength:0;"); nui.get(id).setMaxLengthErrorText("字符数最大长度为" + max); } else if (min > 0 && length < min) { nui.get(id).setVtype("maxLength:0;"); nui.get(id).setMaxLengthErrorText("字符数最小长度为" + min); } else { nui.get(id).setVtype("maxLength:5000;"); } } /** *Description: 校验文本长度是否符合要求 CR-EPPS-20231121-01
* @param name 字段名称 */ function checkLengthByName(name) { var id = this.event.srcElement.name; var value = nui.get(id).getValue(); var length = 0; for (var i = 0; i < value.length; i++) { if (value.charCodeAt(i) > 255) { length += 3; } else { length++; } } if(name == "carType"){ if(length != 10 && length != 12){ nui.get(id).setVtype("maxLength:0;"); nui.get(id).setMaxLengthErrorText("字符数长度为10位或12位"); }else{ nui.get(id).setVtype("maxLength:5000;"); } } } /** *Description: // \/:*?<>"|特殊字符的校验
* @param checkValue 要校验的值 * @param checkName 要校验的字段 * @returns 结果 */ function checkIllegalCharacter(checkValue, checkName) { if (checkValue == null && checkValue == "") { return null; } for (var i = 0; i < checkValue.length; i++) { if ("\\" == checkValue.substr(i, 1)) { return checkName + "中包含非法字符!Description: 校验字符串的长度是否大于最大长度
* @param str 字符串 * @param maxLength 最大长度 * @returns 结果 */ function checkCharacterLength(str, maxLength) { var length = 0; for (var i = 0; i < str.length; i++) { if (str.charCodeAt(i) > 255) { length += 3; } else { length++; } } if (length > maxLength) { return false; } return true; }