Clear form


Well my question is that I must add to the javascripr for when I click on the submit in this case I will clear the text box that in my case is one, that is the textarea. Thanks in advance this is my code

 <textarea id="user_message_textarea"style="resize:none;height:100px;width:700px;" class="form-control" placeholder="Texto que voy a poner en el placeholder"></textarea>
                                                        <button id="user_message_button" type="button" class="button">Enviar</button>
                    <div id="snackbar_nuevo_servicio">Mensaje enviado. Gracias</div>
                            var showing_snackbar = false;
                            function user_message_success(){
                                var x = document.getElementById("snackbar_nuevo_servicio");
                                var b = document.getElementById("user_message_button");
                                x.className = "show_nuevo_servicio";
                                b.className = "btn btn-primary btn-md disabled";
                                showing_snackbar = true;
                                setTimeout(function(){ x.className = x.className.replace("show_nuevo_servicio", ""); showing_snackbar = false; b.className = "btn btn-primary btn-md";}, 3000);

                            if(($("#user_message_textarea").val()).trim()  !== ""){
                            if(showing_snackbar == false){
                            user_message:   $("#user_message_textarea").val()
                            function(data, status){
                            if(status == "success"){

asked by Speakers95 02.12.2018 в 09:12

2 answers


You should do a reset. That is:


In case of not being in a form (because I do not see the label), you can "empty" if you want the textarea, that is:

answered by 02.12.2018 в 11:14

A simple way to delete an input is:

<script src=""></script>
<textarea name="" id="user_message_textarea" cols="30" rows="10">Hola Mundo</textarea>
<button class="borrar">Borrar</button>
answered by 02.12.2018 в 23:51