Bhupesh-V / tutorialdb

A search 🔎 engine for programming/dev tutorials,
MIT License
121 stars 60 forks source link

Search Results are getting rendererd when there is no search string #26

Closed Bhupesh-V closed 4 years ago

Bhupesh-V commented 4 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Go to Home Page
  2. Click on Submit button
  3. See error

Expected behavior Search should not appear until unless there is a Search string

Animesh-Ghosh commented 4 years ago

I think a better way would be to handle searches similar to how search engines handle them.

If the input is empty, we don't submit the form to the back-end.

Something like:

HTML:

<form onsubmit="return checkEmpty()" method="get">
.
.
.
</form>

JS:

function checkEmpty() {
    var input = document.getElementById("search-bar");
    if (input.value == "" || input.value == null) {
        return false;
    }
    else {
        return true;
    }
}

This is the solution thread.

Should I open a PR?

Bhupesh-V commented 4 years ago

I have done the same implementation The submit buttons remains disabled until unless there is a string in input box

Animesh-Ghosh commented 4 years ago

So... wontfix?