How to get an input value using “refs” in react-bootstrap form?

前端 未结 7 756
小蘑菇
小蘑菇 2021-02-05 04:01

I\'m trying to create a form that appears in modal. So when user input a value, that value is stored in local storage. Here\'s a picture that help\'s you to understand what I me

相关标签:
7条回答
  • 2021-02-05 04:59

    Hello this solution worked for me!

    <Form
      noValidate
      validated={validated}
      onSubmit={(e) => this.handleSubmit(e)}
      style={{ width: '100%' }}
    >
      <Form.Group controlId="formBasicEmail">
       <Form.Label>Email address</Form.Label>
       <Form.Control type="email" placeholder="Enter email" inputRef={(ref) => { this.email = ref }} required />
       <Form.Text className="text-muted"> Well never share your email with anyone else.
       </Form.Text>
      </Form.Group>
    </Form>
    
    handleSubmit(event) {
        console.log(event.target.elements.formBasicPassword.value)
    }
    
    0 讨论(0)
提交回复
热议问题