Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

109
Vistas
React Bootstrap Modal not working on submit Button

I am looking to send the value from the Form.Control to the button so I can do some logic but I cannot seem to get this value from the input. I tried using reft but I cant use refs in a functional component, so I'm using the textInput. Please help, been stuck for 3 days. thx

import React from "react";
import { Modal, Form, Row, Col, Button } from "react-bootstrap";
import "./Login.css";

export const ForgotPassword = (props) => {
  let textInput = null;

  const handleClick = () => {
    console.log("i am here", textInput.focus());
  };

  return (
    <>
      <Modal
        {...props}
        aria-labelledby="contained-modal-title-vcenter"
        centered
      >
        <Modal.Header closeButton>
          <Modal.Title id="contained-modal-title-vcenter">
            Forgot Password
          </Modal.Title>
        </Modal.Header>
        <Modal.Body className="show-grid">
          <Form.Label>Please enter your Employee ID.</Form.Label>
          <Row>
            <Col className="lm-qus" md={5}>
              Employee ID:
            </Col>
            <Col md={7}>
              <Form.Control
                type="text"
                required
                name="answer"
                placeholder=""
                ref={(input) => {
                  textInput = input;
                }}
              />
            </Col>
          </Row>
        </Modal.Body>
        <Modal.Footer>
          <Button onClick={props.onHide}>Cancel</Button>
          <Button onClick={handleClick} type="submit">
            Continue
          </Button>
        </Modal.Footer>
      </Modal>
    </>
  );
};

this is what I have, I enter an ID, the when I click continue, I don't have a value there

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This is not a modal specific problem. Make your Form.Control a controlled input by providing "value" attribute. Define state and set this state on change event of the input. You can then access this state everywhere, including the button:

const [value, setValue] = React.useState("");
const handleChange = (event) => setValue(event.target.value);
const handleClick = () => alert(value);

https://codesandbox.io/s/objective-pond-rs8r9f

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda