<html>
<body>
<form name="f" action="http://maps.google.com/" method="get" onsubmit="return check()">
Search: <input type="text" name="q" value=""><br>
<input type="submit" value="Search">
</form>
<script>
function check(){
var floatReg=/^([+-]?)[1-9]\d*(\.\d*)?,([+-]?)[1-9]\d*(\.\d*)?$/;
if(!floatReg.test(f.q.value)){
alert("please try it again");
f.q.value="";
document.f.q.focus();
return false;
}
}
</script>
</body>
</html>
沒有留言:
張貼留言