ASP菜鸟提问:看看我的函数有什么问题!!

tangss 2004-01-09 11:24:55
我是ASP菜鸟,大家帮我看看我的这段代码有什么问题,我调用时只执行submitchecken() 检查是否为空,而不执行(!CheckIfEnglish 判断长度,不知为何!!
<SCRIPT language=javascript1.2>

function CheckIfEnglish( String )
{
var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-";
var i;
var c;
if(String.charAt( 0 )=='-')
return false;
if( String.charAt( String.length - 1 ) == '-' )
return false;
for( i = 0; i < String.length; i ++ )
{
c = String.charAt( i );
if (Letters.indexOf( c ) < 0)
return false;
}
return true;
}
function submitchecken() {

if (document.frmsearchInt.searchetype.value == "") {
alert("请输入您要查询的IC型号");
document.frmsearchInt.searchetype.focus();
return false;
}

if (!CheckIfEnglish(document.frmsearchInt.searchetype.value )) {

alert("请输入至少3位字符");

document.frmsearchInt.searchetype.focus();
return false;
}
document.frmsearchInt.searchType.value = "IntDomain";
return true;
}

</SCRIPT>
...全文
40 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
monkeys 2004-01-09
  • 打赏
  • 举报
回复
function submitchecken() {

if (document.frmsearchInt.searchetype.value == "") {
alert("请输入您要查询的IC型号");
document.frmsearchInt.searchetype.focus();
return false;
}
return true;
frmsearchInt.submit();
}
say1no2 2004-01-09
  • 打赏
  • 举报
回复
调用了啊,不过,你的代码,没有判断是否大于3位!

加上这个吧
if(String.length<3) alert("请大于3个字符");
lbd8848 2004-01-09
  • 打赏
  • 举报
回复
试了一下CheckIfEnglish函数没问题
if (!CheckIfEnglish(document.frmsearchInt.searchetype.value ))
可能没有执行到吧,
ygghost 2004-01-09
  • 打赏
  • 举报
回复
function submitchecken() {

if (document.frmsearchInt.searchetype.value == "") {
alert("请输入您要查询的IC型号");
document.frmsearchInt.searchetype.focus();
}
else if (!CheckIfEnglish(document.frmsearchInt.searchetype.value ))
{

alert("请输入至少3位字符");

document.frmsearchInt.searchetype.focus();

}
else
{
document.frmsearchInt.searchType.value = "IntDomain";

}
}
tangss 2004-01-09
  • 打赏
  • 举报
回复
解决了, lbd8848(lbd) 的可以。
say1no2(海子)的我不知加哪合适。加上以后提示“请大于3个字符"后还是继续往下运行,而我想要的是返回重新输入。
say1no2 2004-01-09
  • 打赏
  • 举报
回复
加上这句就行了啊

if(String.length<3) alert("请大于3个字符");
lbd8848 2004-01-09
  • 打赏
  • 举报
回复
<SCRIPT language=javascript1.2>

function CheckIfEnglish( String )
{
var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-";
var i;
var c;
if(String.charAt( 0 )=='-')
return false;
if( String.charAt( String.length - 1 ) == '-' )
return false;
for( i = 0; i < String.length; i ++ )
{
c = String.charAt( i );
if (Letters.indexOf( c ) < 0)
return false;
}
return true;
}
function submitchecken() {

if (document.frmsearchInt.searchetype.value == "") {
alert("请输入您要查询的IC型号");
document.frmsearchInt.searchetype.focus();
return false;
}

if (!CheckIfEnglish(document.frmsearchInt.searchetype.value) || document.frmsearchInt.searchetype.value.length<3) {

alert("请输入至少3位字符");

document.frmsearchInt.searchetype.focus();
return false;
}
document.frmsearchInt.searchType.value = "IntDomain";
return true;
}

</SCRIPT>
是不是这样呀??
tangss 2004-01-09
  • 打赏
  • 举报
回复
不行啊大家,还是没有判断是否大于3位!

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧