0

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">
</form>
5
  • Any reason not to use the placeholder attribute?
    – fuxia
    Commented Apr 26, 2013 at 16:22
  • @toscho probably that IE < 10 doesnt support it.
    – vancoder
    Commented Apr 26, 2013 at 16:24
  • You must be getting a JS error - what is it?
    – vancoder
    Commented Apr 26, 2013 at 16:27
  • @vancoder no, js works fine, it's just not submitting when I click that input button, nothing happens at all
    – Ilja
    Commented Apr 26, 2013 at 16:28
  • 1
    what about using type="submit" instead of type="button" ?
    – birgire
    Commented Apr 26, 2013 at 16:29

1 Answer 1

2

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 and acknowledge you have read our privacy policy.

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