For all input, is it always necessary to add a value? And how do I make value not change the placeholder?

Asked

Viewed 28 times

-2

I’m creating a simple form with pure HTML from what I learned in Freecodecamp. But I was a little confused on the question of whether or not it is necessary to put value on every input because, in the end, it ends up changing the placeholder that I put.

Is there a rule for adding value to input? And if necessary, how do I not change my placeholder?

My code is like this:

<form>

    <h2>Google</h2>

    <h2>Fazer Login</h2>

    <h4>Use sua conta do Google</h4>
    
    <fieldset>
        <legend>Nome</legend>

        <label for="name">      
            <input id="name" type="text" name="information" placeholder="Digite seu nome" value="name" required>
        </label>
    </fieldset>

    <fieldset>
        <legend>Email</legend>

        <label for="email">
            <input id="email" type="email" name="information" placeholder="Digite seu email" value="email" required>
        </label>
    </fieldset>

    <a href="#">Esqueceu seu e-mail?</a>

    <p>Não está no seu computador? Use o modo visitante para fazer login com privacidade. <a href="#">Saiba Mais</a>.</p>
</form>

2 answers

0


Hello, all right ?

The "value" property of an input refers to the value contained in it.

In your case, you can create the input with the empty value property, (value=""), so that the placeholder appears correctly.

If you create an input and type some value in, what is written in the field becomes "Value", where it will automatically overwrite the placeholder property.

-2

This "value" is optional, not required if the data is not fixed.

Leaves value=""

Browser other questions tagged

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