Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

239
Visualizações
How to Disable Button until Payment Term not selected Reactjs?

Function Base Popup Modal component... Need Help to disable Submit until User not selected any payment term.

//Modal Box Start 
    <Modal show={approveShow} onHide={() => { handleApproveClose() }}>
            <Modal.Body>
              <h3>Are You Sure You Want to Activate the User</h3>
              <hr />
              <div >
                <label>Select Payment Term</label>
                <Select options={PaymentTermList} onChange={onChangePaymentValue}></Select>
              </div>
            </Modal.Body>
            <Modal.Footer>
              <Button variant="primary" onClick={() => { handleApproveClose(); ChangeUserStatusBackend() }}>
                Submit
              </Button>
            </Modal.Footer>
          </Modal>
//Modal Box End

onChangePaymentValue:

function onChangePaymentValue(event) {
    
        console.log(event.value);
        SetPaymentTerm(event.value);
      }
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Assuming onChangePaymentValue is a function that updates state, set the initial state to zero. When you update the state you can change the status of the button. When it's zero disable it. If it's not zero, enable it.

const { useState } = React;

function Example() {

  const [ paymentValue, setPaymentValue ] = useState(0);

  function onChangePaymentValue(e) {
    setPaymentValue(e.target.value);
  }

  function handleClick() {
    console.log('Button clicked');
  }

  return (
    <div>
      <select onChange={onChangePaymentValue}>
        <option selected>Choose a number</option>
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
      </select>
      <button onClick={handleClick} disabled={!paymentValue}>Submit</button>
    </div>
  );
};

// Render it
ReactDOM.render(
  <Example />,
  document.getElementById("react")
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.1/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.1/umd/react-dom.production.min.js"></script>
<div id="react"></div>

about 4 years ago · Juan Pablo Isaza Relatório

0

if payment term's state is like this:

const[PaymentTerm,SetPaymentTerm] = useState(0);

so you need to change onChangePaymentValue to:

function onChangePaymentValue(event) {
        SetPaymentTerm(event.target.value);
 }

And also change button to:

   <Button disabled={PaymentTerm == 0} variant="primary" onClick={() => { handleApproveClose(); ChangeUserStatusBackend() }}>
                Submit
              </Button>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda