submit form with delay while entering data into input field

后端 未结 2 1495
暖寄归人
暖寄归人 2021-02-14 14:51

I have a simple form that I need to submit automatically when text is entered.

I can use the onChange or onKeyUp without the best result.

HTML is:



        
2条回答
  •  离开以前
    2021-02-14 15:08

    This should work. Submits the form when nothing was typed for 500ms

    var timerid;
    jQuery("#fusionSearchForm").keyup(function() {
      var form = this;
      clearTimeout(timerid);
      timerid = setTimeout(function() { form.submit(); }, 500);
    });
    

提交回复
热议问题