Text type input element dropdown with javascript

Asked

Viewed 27 times

0

I’m developing a login page, but the dropdown style of <input> changes in each browser. I have been searching and found that there is no way to change its style with CSS, because that style is unique to each browser.

In my researches I found, still, that it is possible to change the style of the dropdown <select> using javascript, but nothing referring to <input>. (Source: https://www.w3schools.com/howto/howto_custom_select.asp)

When saving multiple logins and passwords, a dropdown appears on <input name="user" id="user" type="text">. I wonder if there is any way to change that style with javascript? Thank you!

<form method="POST" action="/">
    <input type="text" name="user" id="user" placeholder="login"><br />
    <input type="text" name="pass" id="pass" placeholder="password"><br />
    <input type="submit" name="btn" id="btn" value="Send">
<form>

  • Paulo I was a little confused, you just want to style an input, or you’re saying you have a JS that turns your input into a dropdown?

  • It’s not possible, no. That "dropdown" (actually it is not dropdown, it is a kind of "autocomplete" or hint that the browser gives when going storing what was typed) is a feature of the browser and cannot be modified.

  • @hugocsl No and no (rs). It would be more the "browser autocomplete" than I want to change the style.

  • @sam what a pity! I was looking at the js from the w3schools example, but it basically built every item from the <select> using html and css.

  • If you are talking about the autocomplete that the browsed shows vc tb will not be able to customize it by the same fact of select. Mainly the password field that has several limitations... In normal inputs the autocomplete="off" can work, but the pass will not roll... Now if you want to simply customize an input text there are 1000 ways....

  • @hugocsl You understood me the first time. I thought you could customise the same autocomplete. I will keep the post open, to see if anyone has any idea of circumventing this mechanism. Thank you!

  • 1

    https://answall.com/questions/33482/como-remover-preenchimento-autom%C3%A1tico-de-inputs/33490#33490

  • 1

    @hugocsl Perfect! Does not solve the problem of style, but brings several cool maneuvers. Thank you so much for telling me that post! I would never search for ways to block the autocomplete, so it would be hard for me to find that question. Thanks again! Post your answer in the answer so I mark it as "solution".

  • Paul nothing, we are here to contribute. No truth I have no other answer than to pick up the answer from the other post. So the correct thing to do for Stackoverflow is to vote to close the question as Duplicate. You can even accept the Duplicate marking, or if you don’t want it automatically goes to the analysis queue and the Community will vote to close it or not...

  • 1

    @hugocsl Got it! All right! Thanks again! :)

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.