1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!DOCTYPE html>
<html>
	<head>
		<title>lab 20</title>
	</head>
	<body id="body">
		<form name="f" action="http://maps.google.com/maps" method="get" onsubmit="return check()">
		Search: <input  id="cord" type="text" name="q" value="">
		<input type="submit" value="Go">
		</form> 
		
		<script>
			function check(){
				var cordRegex = /[+-.]*\d*[.]\d+[,][+-.]*\d*[.]\d+/;
				if (!cordRegex.test(f.q.value)){
					alert("the cordinate is in wrong form, please retry.");
					f.q.value="";
					document.f.q.focus();
					return false;
				}
			}
	</script>
	</body>
</html>