c# - why javascript ignores changes in default text of the textbox? -


i can't understand why javascript ignores changes of default text of textbox?

more details: textbox has default text 'search'. when client tries submit search form default text, should return false , focus textbox.

<asp:panel cssclass="search rnd" id="searchbox" runat="server" defaultbutton="btnsearch">     <asp:textbox id="txtsearch" runat="server" validationgroup="searchform" maxlength="100" cssclass="text" text="search" onfocus="if ( this.value == 'search') { this.value = ''; }" onblur="if ( this.value == '' ) { this.value = 'search'; }"></asp:textbox>     <asp:button id="btnsearch" runat="server" validationgroup="searchform" cssclass="btn-search" tooltip="search website" onclick="btnsearch_click" onclientclick="if ( document.getelementbyid('<%= txtsearch.clientid %>').value = 'search') { document.getelementbyid('<%= txtsearch.clientid %>').style.background = 'yellow'; document.getelementbyid('<%= txtsearch.clientid %>').focus(); return false; } " />     <asp:requiredfieldvalidator cssclass="hdn rf" id="requiredfieldvalidator1" controltovalidate="txtsearch" runat="server" errormessage="*"></asp:requiredfieldvalidator> </asp:panel> 

please me!

you assigning instead of comparing.

change: if ( document.getelementbyid('<%= txtsearch.clientid %>').value = 'search')

to if ( document.getelementbyid('<%= txtsearch.clientid %>').value == 'search')


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -