<html>

<head>
<script language="JavaScript">
function validator()
{
if (text_form.name.value == "")
{
   alert("Please enter your name"); 
   text_form.name.focus(); 
   return false;
}
return true;

}
</script>
</head>
<body>
<form name="text_form" method="get" action="success.html" onsubmit="validator()">
<label for="name"> Name </label>
    <input type="text" name="name"/> <br />
    <input type="submit" value="submit" />
    <input type="reset" value="reset" />
</form>
</body>

</html>



//whats wrong with my code? eventhough the validation is working, it still goes to the "success.html" helpp!! 


//thanks in advance..

yeah. i forgot the "return"// :) thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.