|
<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="http://www.baidu.com" onsubmit="return check();"> <input type="text" name="test" /> <input type="submit" name="Submit" value="提交" /> </form>
|