<html>
<title>lab14</title>
<body>
<form action="http://maps.google.com/maps" method="get" name="f" onsubmit="return check()">
<input name="q" type="text" /><br />
<input name="send" type="submit" value="search" />
</form>
</body>
<script>
function check(){
var floatReg =/^\d*(\.\d+)?[,]\d*(\.\d+)?$/;
if(!floatReg.test(f.q.value)){
alert("It's not a correct format");
f.q.value="";
document.f.q.focus();
return false;
}
}
</script>
</html>
沒有留言:
張貼留言