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