Search Box validation When Onfocus-Onblur
Hi Sir,
Now i changed my code for search box validation when Onfocus-Onblur or Default text.
and its working very good...!!
My Codes:
<html>
<head>
<title>A Simple Form with JavaScript Validation</title>
<script type="text/javascript">
<!--
function validate_Search()
{
valid = true;
if (( document.mysearch.q.value == "" )||(document.mysearch.q.value == "Search On Google"))
{
alert ( "Please enter your Search string in the box" );
document.mysearch.q.focus();
valid = false;
}
return valid;
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF">
<form name="mysearch" method="get" action="http://www.google.com/search" target="_blank" onSubmit="return validate_Search();">
<fieldset style="width:240px; padding: 10px; -moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px;">
<CENTER>
<input style="color: #4D4D4D;" name="q" id="header-search-text" value="Search On Google" onfocus="this.value=(this.value==this.defaultValue)?'':this.value;" onblur="this.value=(this.value=='')?this.defaultValue:this.value;" type="text">
<input type="submit" id="header-search-submit" value="Search" />
</center>
</fieldset>
</form>
</body>
</html>
please tell, is this right way to get validate?