Explorar o código

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 %!s(int64=11) %!d(string=hai) anos
pai
achega
db79ab6c81
Modificáronse 1 ficheiros con 14 adicións e 2 borrados
  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>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>
         <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">
         <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>
                 <button class="btn" type="button">Search</button>
             </form>
             </form>
         </div>
         </div>
     </div>
     </div>
 </div>
 </div>
 {% endblock content %}
 {% 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 %}