Java Script Validation Sample Code in HTML in TGMC

<html>

<head>

<title>A Simple Form with JavaScript Validation</title>

<script type="text/javascript">

<!--

function validate_form ( )
{
valid = true;

if ( document.contact_form.contact_name.value == "" )
{
alert ( "Please fill in the 'Your Name' box." );
valid = false;
}
if ( document.contact_form.contact_name.value != "" )
{
alert ( "Succesfull" );
valid = false;
}
return valid;

}

//-->

</script>

</head>

<body bgcolor="#FFFFFF">

<form name="contact_form" method="post" onSubmit="return validate_form ( );">

Please Enter Your Name

<p>Your Name: <input type="text" name="contact_name"></p> <p><input type="submit" name="send" value="Send Details"></p> </form> </body> </html>