Goran
Goran

Reputation: 6824

React get form field value in onSubmit

I'm trying to understand pretty basic things but seems I'm lost trying to get form field value in onSave function. I have one field in form only <input name='content'>

_onSubmit: function(e) {
    e.preventDefault();

    var content = e.content.value;

but it respond in console with TypeError: e.content is undefined

Upvotes: 0

Views: 1800

Answers (1)

Dzhakhar Ukhaev
Dzhakhar Ukhaev

Reputation: 305

You can get input's value using

e.target.value

Or

e.preventDefault()
let value = document.getElementById("myinput").value;
let valu2 = document.getElementById("myinput2").value;
...

Upvotes: 1

Related Questions