<html>
<title>Lab20 </title>
<body>
<form action="http://maps.google.com/maps" method="GET" name="f" onsubmit="return check()">
Search Position: <input name="q" type="text" />
<input type="submit" value="提交資料" />
</form>
<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>
</body>
</html>
沒有留言:
張貼留言