Frage

I have a password input element and and some radio buttons on an HTML form -- a login form for a web site. When the user enters text in the password input box, it should select one of the radio buttons. I do this by selecting the radio button in the password input's onKeyUp handler.

However, some users use their browser's password save feature, which automatically fills in the password (and other text input fields) on the form. However, at least on Chrome and Firefox, the password auto-fill does not save the state of the radio buttons on the login form.

I need to select this radio button when the browser auto fills the password input, in the same way I select it when the user types in the password input.

Is there another event besides onKeyUp that will fire when the browser fills in the text? If not, is there some other way I can accomplish this?

Goal: Select a radio button if a password is entered in a password input, whether it's entered by keyboard or filled in by browser.

War es hilfreich?

Lösung

You can trigger the keyup event when the page loads, so it will do your work if some text is been written on that filed by the browser.

setTimeout(function() {
     $('#your_field').trigger('keyup');
},250);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top