I have a react formik form, where there is a select field, say the field has values A,B,C,D,E,F.
now say, another field , ChooseSubType , only shows up if I choose B or D and this field will only be a required field when it shows up and not before that.
now, how do I make that work?
here's code for the first field i.e. select field
chooseAlphabet: Yup.string().required('field required'),
chooseSubType : Yup.string().when('chooseAlphabet',
('chooseAlphabet',schema)=>{
console.log('value business : ',chooseAlphabet);
if(chooseAlphabet === "B"||"D"){
return schema;
}else{
return schema.required('field required');
}
}),
but this code isn't working.
now, what changes do I make here to make this work as I want it to?
chooseSubType
isn't showing up? – Incensory