Input and reset problems

Asked

Viewed 32 times

0

Why the 2 input elements placed at the end of the code are doing nothing?

<!DOCTYPE html>
<html>
<head>
</head>
<body>
    <form action="https://Example.com" method="get">
        <div>
            <label for="nome">Nome:</label>
            <input type="text" id="nome" size="10" required="nome"/>
        </div>
        <div>
            <label for="senha">Senha:</label>
            <input type="password" id="senha" size="5" maxlength="6" required="senha"/>
        </div>
        <div>
            <button type="submit">Cadastrar</button>
        </div>
    </form>
    <fieldset align="center">
         <h3>Se você gostou, não deixe de avaliar</h3>
         <label><input type="radio" name="avaliar" value="b"/>Bom</label>
         <label><input type="radio" name="avaliar" value="m"/>Médio</label>
         <label><input type="radio" name="avaliar" value="r"/>Ruim</label>

         <label for="comments"></label>
         <br/>
         <textarea rows="6" cols="40"></textarea>
         <br/>
         <label><input type="submit" name="Enviar"></label>
         <label><input type="reset" value="Apagar"></label>
         <br/>     
    </fieldset>
</body>
</html>

Type reset should not delete the texts and Submit should redirect to Example.com?

2 answers

3


You put your inputs Submit and reset off tag <form>, then to have a btn out of the form, but make reference to it you need to use the attribute form="" in the tag of <input>, and in that form="" you put the name you declare in ID that you tag <form>

Example:
In input the form would look like this: <input form="meuForm" type="submit">

And on the form tag you put an id: <form id="meuForm">

As below

<form action="https://Example.com" method="get" id="meuForm">
    <div>
        <label for="nome">Nome:</label>
        <input type="text" id="nome" size="10" required="nome"/>
    </div>
    <div>
        <label for="senha">Senha:</label>
        <input type="password" id="senha" size="5" maxlength="6" required="senha"/>
    </div>
    <div>
        <button type="submit">Cadastrar</button>
    </div>
</form>
<fieldset align="center">
      <h3>Se você gostou, não deixe de avaliar</h3>
      <label><input type="radio" name="avaliar" value="b"/>Bom</label>
      <label><input type="radio" name="avaliar" value="m"/>Médio</label>
      <label><input type="radio" name="avaliar" value="r"/>Ruim</label>

      <label for="comments"></label>
      <br/>
      <textarea rows="6" cols="40"></textarea>
      <br/>
      <label><input type="submit" name="Enviar" form="meuForm"></label>
      <label><input type="reset" value="Apagar" form="meuForm"></label>
      <br/>     
</fieldset>

-1

Both must be inside the form, in your case you are closing the tag form before the input.

Browser other questions tagged

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