Prevent input from having default text

Asked

Viewed 51 times

0

How do I prevent that when opening a form, inputs are empty and have no text by default.

Basically what I want is for the inputs to be without any associated value. In this case the password is already there, but I wish it was always empty.

inserir a descrição da imagem aqui

And when writing that it did not present the list of options previously written. (as in the image below)

inserir a descrição da imagem aqui

  • This depends on the browser settings. Your browser is probably saving the fill options. Change these settings and the problem will be solved.

  • But it does not guarantee me what I want for users. I want to prevent this situation for all users.

1 answer

3


hello have you used Jquery? see how easy it is to solve your problem with it.

<html>
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
        <script>
            $(function(){
                $('input').val('')
            })
        </script>
    </head>
    <body>
        <form>
            <input type="password" value="123" placeholder="digite sua senha"  autocomplete="off" />
            <input type="text" value="oie" placeholder="digite um texto"  autocomplete="off" />
        </form>
    </body>
</html>

in the example I used, every time I load/open the page the fields will be cleared, you can adapt the code as you want.

Placeholder = is to enter something in the field for the user to read

Autocomplete = is to enable or not the list of information already entered in the field hope I’ve helped

Browser other questions tagged

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