Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
38
rated 0 times [  40] [ 2]  / answers: 1 / hits: 82835  / 11 Years ago, fri, january 31, 2014, 12:00:00

I have a simple form with one text field for testing. I need to have the info the user types in sent to console.log for now. Is this possible and if so what would I write?



<form class=pure-form>
<input id=name type=text placeholder=Enter Name />
<button type=submit><i class=fa fa-chevron-circle-right></i></button>
</form>

More From » javascript

 Answers
5
var nameInput = document.getElementById('name');

document.querySelector('form.pure-form').addEventListener('submit', function (e) {

//prevent the normal submission of the form
e.preventDefault();

console.log(nameInput.value);
});

[#72805] Thursday, January 30, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
shamya

Total Points: 38
Total Questions: 101
Total Answers: 96

Location: Thailand
Member since Thu, Apr 22, 2021
3 Years ago
;