Input onkeypress check if value emtpy - any ideas?

Hi All,

I need some Javascript code to allow an input "search" to constantly check it the value is empty onkeyup and if so fire an action.


<form id="searchform" name="searchform">
<input name="search" id="search" onkeyup="ACTION HERE">

For the purposes of this if someone could provide a full source snippet so that when using the input on keyup the input checks if the input box is empty and fires a message saying "empty" or similar.

I can then take it from there.

Thanks in advance for all help given.

Who is Participating?

<script type="text/javascript">
function checkEmpty(field) {
  if(field.value.length < 1) {
spiroosxAuthor Commented:
That's great! Thank you for your help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.