Text box Validation when it have onfocus and onblur event
Dear sir,
i posted here two types of search boxes, both are linked with google.
first one have onsubmit validation when the empty text in the box,
and second one have Default text with onfocus and onblur events.
now the problem is how can i include onsubmit validation for second one? that should be act when it have onfocus default text in textaria or empty text in the box?
Here is the code:
<html>
<head>
<title>A Simple Form with JavaScript Validation</title>
<script type="text/javascript">
<!--
function validate_form ( )
{
valid = true;
if ( document.search_form.q.value == "" )
{
alert ( "Please fill something in the box, then 'Search' " );
valid = false;
}
return valid;
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF">
<!-- Search box-1 -->
<form name="search_form" method="get"
action="http://www.google.com/search" target="_blank"
onSubmit="return validate_form ( );">
<fieldset style="width:400px;">
<p>Search On Google: <input type="text" name="q">
<input type="submit" name="send" value="Search"></p>
</fieldset>
</form>
<!-- Search box-2 -->
<form name="search" method="get" action="http://www.google.com/search" target="_blank" >
<fieldset style="width:400px;">
<input style="color: #4D4D4D;" name="q" id="header-search-text" onfocus="this.value=''" value="Search On Google" onblur="this.value=this.value==''?'Search On Google':this.value;" type="text">
<input type="submit" id="header-search-submit" value="Search" />
</fieldset>
</form>
</body>
</html>
looking forward to you..
please guide me..
with thanks