javascriptdom-eventsunobtrusive-javascript

Checking if contents of a field were changed via a program. What event will be triggered


I have a password field that, because it has it's field name inside it, begins as an input="text". When the user types or clicks on it, the field swaps out to input="password".

Some of our users store their username/password into a 3rd party program. Because the password is being written into the field via one of their functions, my password field isn't swapping out to a password because there's no event firing against it.

The third party folks aren't on the ball and really just said, "tough".

I was thinking of doing a setInterval to check the contents, but this will not be immediate enough.

Does anyone if any event fires if the contents of an input field is changing via a function. Again, I have no control over the function that is inputting the password.

Any suggestions would be a help. I feel as if this is a lost cause. BTW, I can't use jQuery because it's not an approved technology on our site. But, if there is a jQuery solution, I can see what I can do.


Solution

  • For your situation, you could reverse your logic. You can start the field as "password", then on setTimeOut, check if it has a value of 'password'. If it does, set it to "text".

    (You could further use 'onchange' and backend validation to disallow the word password as a password)