I've got a search form on my page, which works perfectly fine when I enter the text and press enter, however it doesn't submit anything when .submit-search button is clicked, why is that? note: value="2" is there for specific use.

<form action="<?php echo home_url(); ?>" class="search-form" method="get">
<input class="search-input" type="text" value="Search..." name="s" id="s" 
onblur="if(this.value == '') this.value = 'Search...'" 
onfocus="if(this.value == 'Search...') this.value = ''">
<input class="submit-search" type="button" value="2">
  • Any reason not to use the placeholder attribute? – fuxia Apr 26 '13 at 16:22
  • @toscho probably that IE < 10 doesnt support it. – vancoder Apr 26 '13 at 16:24
  • You must be getting a JS error - what is it? – vancoder Apr 26 '13 at 16:27
  • @vancoder no, js works fine, it's just not submitting when I click that input button, nothing happens at all – Ilja Apr 26 '13 at 16:28
  • 1
    what about using type="submit" instead of type="button" ? – birgire Apr 26 '13 at 16:29

I suggest you use <input type="submit" /> or <button type="submit" />.

<input type="button" /> is valid but doesn't submit the form by default (without you adding any ajax/js magic to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.