diff --git a/frontend/src/utils/stockValidator.ts b/frontend/src/utils/stockValidator.ts index edbbc58..0c20ee4 100644 --- a/frontend/src/utils/stockValidator.ts +++ b/frontend/src/utils/stockValidator.ts @@ -1,4 +1,4 @@ - /** +/** * 股票代码验证工具 * 用于验证不同市场类型的股票代码格式 */ @@ -24,6 +24,7 @@ export const validateAStock = (code: string): boolean => { // 深圳证券交易所股票代码以0或3开头,6位数字 // 科创板股票代码以688开头,6位数字 // 北京证券交易所股票代码以8开头,一般为5位数字(如80XXX) + // 北交所科技创新板块股票代码以43开头,6位数字 // 注意:中小板、创业板代码格式已合并处理 // 验证上海证券交易所(以6开头的6位数字) @@ -47,6 +48,11 @@ export const validateAStock = (code: string): boolean => { return true; } + // 验证北交所科技创新板块(以43开头的6位数字) + if (code.startsWith('43') && /^\d{6}$/.test(code)) { + return true; + } + return false; }; @@ -103,7 +109,7 @@ export const validateStockCode = ( if (!validateAStock(code)) { return { valid: false, - errorMessage: `无效的A股股票代码格式: ${code}。A股代码应以0、3、6、688或8开头,且为6位数字或5位数字` + errorMessage: `无效的A股股票代码格式: ${code}。A股代码应以0、3、6、688、8或43开头,且为6位数字(北交所8开头为5位数字)` }; } break;