Browse Source

Fix- Search form in 404 will not search at all

Check used to look for main navigation tipue_search_input value.length which was empty.
On the other hand 404 search form has value in it.

This fix checks for the value of 404 search form separately.
Talha Mansoor 11 years ago
parent
commit
db79ab6c81
1 changed files with 14 additions and 2 deletions
  1. 14 2
      templates/404.html

+ 14 - 2
templates/404.html

@@ -20,11 +20,23 @@ Page does not exist at {{ SITENAME|striptags }} blog.
         <p>Sorry, but the page you are looking for cannot be found. It seems that the page you were trying to reach doesn't exist, or may be it has just moved, or it no longer exists.</p>
         <p>The best thing to do is to use the search form or start again from the <a href="{{ SITEURL }}">home page</a>.</p>
         <div class="input-append">
-            <form action="{{ SITEURL }}/search.html">
-                <input type="text" class="span12" placeholder="Search" name="q" id="tipue_search_input">
+            <form action="{{ SITEURL }}/search.html" onsubmit="return validateForm404()">
+                <input type="text" class="span12" placeholder="Search" name="q" id="tipue_search_input_404">
                 <button class="btn" type="button">Search</button>
             </form>
         </div>
     </div>
 </div>
 {% endblock content %}
+
+{% block script %}
+{{ super() }}
+        <script>
+            function validateForm404()
+            {
+                var query_404 = document.getElementById('tipue_search_input_404');
+                return (typeof(query_404) != 'undefined' && query_404 != null && query_404.value.length > 0);
+            }
+        </script>
+
+{% endblock script %}