Chinaunix首页 | 论坛 | 博客
  • 博客访问: 29950995
  • 博文数量: 708
  • 博客积分: 12163
  • 博客等级: 上将
  • 技术积分: 8240
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-04 20:59
文章分类

全部博文(708)

分类: 系统运维

2008-04-24 14:40:17

<script language="javascript">
function check()
{
temp=document.form1.test.value;
   result=temp.split("-");
   if(result.length!=2)
   {
     alert("input is wrong");
     return false;
    }
   if(isNaN(result[0]))
   {
     alert("input is wrong");
     return false;
    }
   if(isNaN(result[1]))
   {
     alert("input is wrong");
     return false;
    }
   return true;
}
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="" onsubmit="return check();">
<input type="text" name="test" />
<input type="submit" name="Submit" value="提交" />
</form>

阅读(1841) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~