0

I have simple code that checks to see if there is a value in an input field, and if there is it gives a Javascript alert window:

 window.setInterval(function(){
    if (!jQuery('#input_74_1').attr('value')) {
        alert('There is no value in the field');
    } else {
        alert('There is a value in the field');
    }
  }, 1000);

The input field in question is an auto-complete field, so that when I type a letter, suggestions are displayed below the input field. When I click on one of the suggestions, it fills the input field with that value.

However, when I first go to the page I get an alert box "There is no value in the field", but when I start typing and select a suggestion, the input field is filled with the value I selected, but I don't get an alert box that says "There is a value in the field". If this function is set to run every second, shouldn't it be able to tell that there is now a value in the input field, and then display the "There is a value in the field" alert box?

Alex Douglas
  • 534
  • 1
  • 8
  • 21

0 Answers0