0
all right?
Can you give me a help related to the selection of text typed by a user in a form? I’ve tried some solutions I found here, but they didn’t work. I’ve also tried different approaches with pure Javascript, but I haven’t succeeded.
The form is inside an Asp.Net View MVC and I need to take the data entered by the user on the page to send to the Controller.
The sent function Data() is with the attribution/sending information for the controller. Debugging I can see that the function is being successfully called, but the variables that should be with the entered values are "null".
Form:
<p class="text-center">Dados para cadastro: </p>
<form>
<div class="col-md-12 form-group">
<label for="nome">Nome: </label>
<input type="text" class="form-control" id="nome" placeholder="Nome.">
</div>
<div class="col-md-12 form-group">
<label for="email">E-mail: </label>
<input type="email" class="form-control" id="email" placeholder="E-mail.">
</div>
<div class="col-md-12 form-group">
<label for="telefone">Telefone: </label>
<input type="text" class="form-control" id="telefone" placeholder="Número de contato.">
</div>
<div class="col-md-12 form-group">
<button type="submit" class="botaogrande btn btn-primary" onclick="enviarDados()">Cadastrar</button>
</div>
</form>
Attempt to select with jQuery:
var dadosNome = $("#nome").text();
var dadosTelefone = $("#telefone").text();
var dadosEmail = $("#email").text();
From now on, thank you very much.
Hello Bruno, try to capture the values with this method : (var dataName = $("#name"). val(); ).
– Bruno
It worked perfectly, thank you very much. :)
– Bruno
Welcome Bruno, don’t miss a tour of the site. https://answall.com/tour Mark reply as accepts https://i.stack.Imgur.com/jx7Ts.png Why mark reply as accepts https://pt.meta.stackoverflow.com/questions/1078/como-e-por-que-acceptuma-resposta/1079#1079
– user60252