Workaround to avoid empty queries in Search box


I have a Search box and use this code to make sure there will be no empty queries

<form action="Search1.php" method="POST">
       <input type="text" class="textinput" pattern=".{3,}" required title="3 characters minimum required" placeholder="Enter destination" name="keyword" id="keyword" size="20">
        <input type="submit" value="Search" class="button" >

It works fine, except in IE8 and IE9. What can I do to accommodate these rascals?

Any workaround in javascript?

Hi there qim,

putting aside IE8 and IE9 for the moment,are you
aware that the form will submit with three spaces? :cold_sweat:


I mean follow this procedure: focus the input,
tap the space bar three times, click “Search”
and the form will submit. :ng:


Are you aware that as of earlier this week that the only version of IE that Microsoft supports is IE11?

All the other versions of IE are now completely unsupported and can be presumed to have unpatched security holes in them.

Hi felgall

It may be just an academic issue for me, but the fact is that I still get quite a few IE8 and IE9 visitors, mostly IE8

1 Like

If so then you really should treat it as an
historic rather than a coding issue. :ok:

Nevertheless, as I am fully aware of your
quirkiness, try this…


untitled document

After dusting of my old steam powered
XP machine, I eventually managed to
test the code in IE8.

As for IE9, I do not know where to find
that browser. :cold_sweat:


It doesn’t work.

Besides, you don’t know what I am trying to achieve.

Well then, what have you omitted to tell us?

Well, it does for me. :sunglasses:

The form submits when three characters or spaces are entered. :ok:


That’s not what I am after, as per the OP.

  1. Your original post’s requirements were …[quote=“qim, post:1, topic:212384”]
    I have a Search box and use this code to make sure there will be no empty queries
    My reply to that…[quote=“coothead, post:2, topic:212384”]
    putting aside IE8 and IE9 for the moment, are you
    aware that the form will submit with three spaces?
    Your reply to that appears to have been deleted. :ng:

Well, you’re certainly not wrong there, squire. :confused:


An empty query is one with nothing entered, not even spaces

in that case, just change this…

if(ke.value.length<3) {

…to this…

if(ke.value.length===0) {


Still doesn’t work, but leave it, I will try something different.


How many times have I heard you say that?

The code that I gave you works on my IE8.


I am trying with IE11 emulator, and it does not work there with either 8 or 9.

I think the answer is to disable the button if 8 or 9 is detected

Well, I took the trouble, especially for you,
to test my code in the browser that you
specified in your original post - IE8.

The least that you can do, is not to claim
that it does not work until you have also
tested it in IE8.

Of course, what I should really do is just
ignore your aggravating posts altogether. :mask:


1 Like

aggravating posts?..

Thank you anyway

They are aggravating when you bluntly assert that
something does not work without actually testing it.

What do you mean by “anyway”?

Just test the code properly in an IE browser, and then
report your findings.

Does that not seem a reasonable request?


Two hours later

I discover that you do not actually have an IE8 browser
for testing purposes :cold_sweat:

So please never state in that dismissive manner that it doesn’t work.

It really is very aggravating. :ok:


1 Like

Try this:

Search “cities” using JavaScript