function checkString(str) { if (str.substring(0, 3) === 'C00' && str.length === 9) { return true; } else { return false; } }

// 兼容旧版的IE function checkStringIE(str) { if (str.slice(0, 3) === 'C00' && str.length === 9) { return true; } else { return false; } }

JavaScript 判断字符串是否以 'C00' 开头且长度为 9 (兼容旧版 IE)