0

I want to add required attribute in MUI TextField based on a condition.


Var flag = false
If (investment>50000 && investment<5000){
flag = true
}

<TextField 
required = {flag}
id="shop-name" 
label="Shop Name" 
variant="outlined" />

This doesn't seems to work

1 Answers1

0

Seems you have your if statement in the wrong way and you wanted the investment number to be between 50000 and 5000. So change it to

if (investment > 5000 && investment < 50000) {
  flag = true;
}
Akis
  • 1,806
  • 2
  • 10
  • 12