输入筐长度检测

张新杰技术博客 2004-09-27 04:28:10
表单利有多个输入筐,第一个是 kahao 用户输入的长度为10位,多了或少了,就能提示错误后返回。对了就没提示
...全文
71 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ouyi2002 2004-09-27
  • 打赏
  • 举报
回复
补漏掉的一个函数IsDigit1。

function IsDigit1(cCheck)
{
return (('0'<=cCheck) && (cCheck<='9'))
}
ouyi2002 2004-09-27
  • 打赏
  • 举报
回复


personnm=document.sform1.personalid.value;
if (personnm=="")
{
alert("您的证件号码不能为空");
document.sform1.personalid.focus();
return false;
}

for (nIndex=0; nIndex<personnm.length; nIndex++)
{
cCheck = personnm.charAt(nIndex);

if (!(IsaNull(cCheck)))
{
alert("证件号码不能是空格");
document.sform1.personalid.focus();
return false;
}
if (!(IsDigit1(cCheck)))
{
alert("证件号码只能使用数字");
document.sform1.personalid.focus();
return false;
}
}


if ((personnm.length != 15) && (personnm.length != 18))
{
alert("您的身份证号码必须是15位或18位的数字");
document.sform1.personalid.focus();
return false;
}


简单贴一段对于身份证号码的限制。
danjingwu 2004-09-27
  • 打赏
  • 举报
回复
if(document.form1.kahao.value.length!=10){
alert("Error!");
return false;
}

zltostem 2004-09-27
  • 打赏
  • 举报
回复
if(document.formname.kahao.value.length != 10){
alert("kahao有错");
}
zhwb36 2004-09-27
  • 打赏
  • 举报
回复
上面写错了,是document.formname.kahao.length != 10
wittyWYZ 2004-09-27
  • 打赏
  • 举报
回复
<input name="kahao" type="text" size="15" maxlength="10">
zhwb36 2004-09-27
  • 打赏
  • 举报
回复
if(document.formname.kahao != 10)
alert("Error!");
wittyWYZ 2004-09-27
  • 打赏
  • 举报
回复
直接限制输入的长度为10位不就可以了,超过10就不能输入。只能输入等于或少于10为的。
mind_1220 2004-09-27
  • 打赏
  • 举报
回复
if(document.formname.kahao.value==""){
alert("kahao不能为空");
}

28,391

社区成员

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

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