Compare commits
No commits in common. "b7d7a3963aae6c852119e5088053f1fcab41ba8b" and "f8138c7ffb600ce8eec896b083efd2f75142ef26" have entirely different histories.
b7d7a3963a
...
f8138c7ffb
|
|
@ -24,16 +24,26 @@ export function WeatherSearchForm() {
|
|||
setInputError('请输入城市名称');
|
||||
return;
|
||||
}
|
||||
if (trimmedCity.length <2) {
|
||||
if (trimmedCity.length < 2) {
|
||||
setInputError('请输入至少2个字符');
|
||||
return;
|
||||
}
|
||||
if (!/^[\u4e00-\u9fa5a-zA-Z\s-]+$/.test(trimmedCity)) {
|
||||
setInputError('请输入有效的城市名称');
|
||||
if (!/^[a-zA-Z\s]+$/.test(trimmedCity)) {
|
||||
setInputError('请输入字母和空格');
|
||||
return;
|
||||
}
|
||||
await searchWeather(trimmedCity);
|
||||
|
||||
|
||||
if (trimmedCity.length < 2) {
|
||||
setInputError('请输入至少2个字符');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!/^[a-zA-Z\s]+$/.test(trimmedCity)) {
|
||||
setInputError('请输入字母和空格');
|
||||
return;
|
||||
}
|
||||
await searchWeather(trimmedCity);
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Reference in New Issue