I am tempted to send a formlario without the ultimalization of the Ubmit input

Asked

Viewed 36 times

-1

I was wondering if it’s possible to submit a <form> as a standard text:

<form method="POST" action="#">
    NOME
</form>

When you click on the text NAME it must submit the form.

2 answers

2


Uses a label with a for for a input:submit that is hidden with display:none. So when you click on label it triggers the submit. With this technique you don’t need JS

#subi {
    display: none;
}
<form action="action.php">
    <label for="subi" role="button" aria-label="enviar">nome</label>
    <input id="subi" hidden type="submit" value="envia">
</form>

OBS: Just keep in mind how you will treat the semantics and accessibility of this... I recommend using the role and the aria-label and put also the attribute hidden in the input that you want to hide from screen readers

0

You can create an event with javascript (jQuery) with a trigger in the field you want, as long as you can identify it in some way. Example:

<form method="POST" action="#" id="formulario">
    <div id="submeter">NOME</div> 
</form>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
$( document ).ready(function() {
    $('#submeter').on('click', function(){
        $('#formulario').submit();
    });
});
</script>

Browser other questions tagged

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