event binding
event binding
When i hit enter in the text box or click search button, i am not going into that forms submit.
JS
-
<script language="javascript" type="text/javascript">
$("#search_form").submit(function()
{
alert(1)
var searchValue = ''+$('#q').val();
var defaultValue = 'Enter Keywords';
alert(2)
if(defaultValue.toUpperCase() == searchValue.toUpperCase() || searchValue.toUpperCase() == ''){
$("#msgboxGoogleSearch").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('No search provided...').addClass('messageboxerror').fadeTo(900,1);
});
return false;
}
else{
return true;
}
});
</script>
HTML
-
<form id="search_form" name="search_form" method="GET" action="http://googlebox.com/search">
<input type="text" id="q" name="q" value="Enter Keywords" class="textBox swap_value">
<input type="image" src="/images/structure/btn_search_boxYellow.gif" width="20" height="17" class="searchButton" id="GoogleSearch" name="GoogleSearch" alt="Search" title="Search" />
</form>
<span id="msgboxGoogleSearch"></span>
Thank you