Rupam
Rupam

Reputation: 77

Condition for Input field to enter less amount compared to other Input field in React

I have 2 input values named Budget and Earning, so I want Budget to be entered only if it is less than Earning, otherwise no.

How should I condition them: can we use a ternary operator here?

<BudgetInput value={BudgetInputValue}>
<EarningInput value={EarningInputValue}>

Upvotes: 1

Views: 252

Answers (1)

sakshya73
sakshya73

Reputation: 7162

You can use the disabled prop in the input element...and add the condition like:

disabled={BudgetInput >= EarningInput}

Upvotes: 1

Related Questions