How do I make it so that the summit button only works when something is typed in the search box? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I make it so that the summit button only works when something is typed in the search box?

Search box summit button

6th Dec 2016, 6:39 PM
Rafiel
Rafiel - avatar
4 Answers
+ 1
add a 'required' attribute to a search box (without quotes of course)
6th Dec 2016, 6:56 PM
Demeth
Demeth - avatar
0
that worked thanks
6th Dec 2016, 7:17 PM
Rafiel
Rafiel - avatar
0
you can use php script to check if the search input field is empty, such that when it is empty then the page will die the execution of the script and reload back or echo something out for u informing you of the empty field but the easiest and simple way out is the HTML property " required " which will always detect empty field for u.
24th Dec 2016, 9:23 AM
Cele Prince
Cele Prince - avatar
0
Java script can as well do the same as the php script even faster depending on your coding capacity because it needs no reload before outputting unlike php which a server side script
24th Dec 2016, 9:26 AM
Cele Prince
Cele Prince - avatar