Look at the attribute of form tag onsubmit="return validate();".
<html>
<head>
<title>Validate before submittitle>
<script language=javascript>
function validate()
{
var v = document.getElementById("SearchString").value;
if(v.length == 0)
{
alert("No input given");
return false;
}
return true;
}
script>
head>
<body>
<form name="myform" action="http://www.google.com/search" method="GET" onsubmit="return validate();">
Search String: <input type="text" id="SearchString" size="25" value="" name="q">
<br> <input type="submit" value="Search in Google"><br>
div>
form>
body>
html>
0 Comments:
Post a Comment