<div style="margin-right: 10px;"> <input value="Search..." class="custom-search" type="text" name="q" size="25" maxlength="50" /> </div> PHP: How can I make the search box clear the text upon user click? I want thinking something along the lines of onfocus=\"this.value=''\" />   but I got a PHP error as a result. Any help is always appreciated
Have you tried just onFocus=" "? If you are using your example for the onFocus then you are missing some quotes around this which is why the error may be occurring...
use placeholder attribute <input type="text" name="q" size="25" maxlength="50" value="" placeholder="Search..." class="custom-search" /> Code (markup):
javascript: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready( function(){ $("#text").focus( function(){ $(this).val=""; }); }); </script> Code (markup): html: <input type="text" name="q" size="25" maxlength="50" value="" placeholder="Search..." class="custom-search" id="text" /> Code (markup):