Detecting autocomplete on form input with jQuery

前端 未结 9 1804
闹比i
闹比i 2020-12-15 03:50

I have a form that detects if all the text-fields are valid on each keyup() and focus(); if they\'re all valid, it will enable the submit button for the user to press. Howev

9条回答
  •  轮回少年
    2020-12-15 04:08

    I wanted a very good user experience on a field where it would not be invalid (turn red in my case) as long as the user was reasonably active e.g. still filling out the field.

    To do this for normal input, I was able to hook up to keyup with a debounce function, while blur is connected for immediate validation. While it appears that keyup is triggered by lastpass, since I have debounced it, there was a delay in validation. Thanks to @peter-ajtai I tried to add the change event and it indeed catches last pass and leaves the other niceties alone.

    Coffeescript example:

    @fieldExp .keyup($.debounce(@_onExpChange, 3000)) .blur(@_onExpChange) .change(@_onExpChange)

    This worked well and lastpass form fill triggers immediate validation.

提交回复
热议问题