because the placeholder is not shown in my textarea

2

This is my html file:

<!DOCTYPE html>
<html>

  <head>
       <!--aquí van los metadatos --> 
       <meta charset="utf-8">
       <title>Ejemplo formulario atributos</title>
       <link rel="stylesheet" href="css/ejemplo_form_atributos.css"/>º
  </head> 

  <body>
    <!--aquí va el contenido -->
    <h1>Ejemplo formulario atributos</h1>
        <form method="get"
            action="xxxx">
            <fieldset>
                <legend>Datos a rellenar por la administración</legend>
                <label>Nombre del curso</label>
                <input name="nombre_curso"
                    value="Creación páginas web" readonly>
        <br/><br/>
                <label>Código del curso</label>
                <input name="código_curso"
                    value="2015/F1710031" readonly>
        <br/>
            <fieldset>
                <legend>Datos personales</legend>
                <label>Nombre*</label>
                <input name="nombre_alum" maxlength=10 
                    autofocus required/>
                <label>Apellidos*</label>
                <input name="apellidos_alum" maxlength=30 required />
        <br/><br/>
                <label>Documento*</label>
                <input name="documento" placeholder="escriba su DNI"
                        required />
                <label>Edad*</label>
                <input name="edad" placeholder="Mayores de 18"
                <type="number min" min="18" required />
        <br/><br/>
                <label>Observaciones</label>
                <textarea  name="notas" rows=3 cols=20 
            placeholder="Si necesita, escriba aquí sus observaciones">
            </textarea></fieldset>
        <br/><br/>
            <button>Enviar</button>
        </form>
  </body>       
</html>
    
asked by antonio san roman polanco 06.04.2016 в 16:43
source

2 answers

8

The problem is how the code of textarea is written. As it is now there are blank spaces between the tags:

                <textarea  name="notas" rows=3 cols=20 
            placeholder="Si necesita, escriba aquí sus observaciones">
            </textarea>

Blanks and line breaks in front of the closing tag </textarea> matter because they are considered part of the field value. In fact, if you notice, you can click inside the field and you will see that they are there.

The solution is simple: make the closing tag stick to the opening tag. Then you will not have problems with blank spaces or line breaks interpreted as a value and the placeholder will show up without problems:

                    <textarea  name="notas" rows=3 cols=20 
                placeholder="Si necesita, escriba aquí sus observaciones"></textarea>
    
answered by 06.04.2016 в 17:28
0

Your code is well messed up, you have many things that do not close where it should be.

I can share a part of my code for a form, I am learning to use bootstrap, it will help you a lot.

                    <!-- <form role="form" class="content">
                        <div class="header">
                              <h3>ES MOMENTO DE PROGRAMAR UN CAMBIO</h3>
                              <p>Dejanos tus datos aqui</p>
                        </div> 
                        <div class="form-group texto">
                            <div class="form-group">
                                 <input type="nombre" class="form-control info" id="nombre" placeholder="Escribe aquí tu nombre">
                             </div>
                            <div class="form-group">
                                <input type="correo" class="form-control info" id="correo" placeholder="Escribe aquí tu correo">
                            </div>
                            <div class="form-group">
                                <input type="telefono" class="form-control info" id="telefono" placeholder="Escribe aquí tu telefono">
                            </div>
                            <div>
                                <textarea class="form-control info" rows="3" placeholder="Escribe aqui tu mensaje"></textarea>
                            </div>
                            <div class="checkbox">
                                <label>
                                <input type="checkbox" class="btn_select"> Acepto los terminos y condiciones
                                </label>
                                <button type="submit" class="btn btn-primary ">ENVIAR</button>
                          </div>
                        </div>
                    </form> -->

It's just a matter of order too.

    
answered by 07.09.2017 в 23:22