我正在使用Reactstrap v8.0.1
,我试图显示错误消息并用红色边框显示该字段,但似乎根本无法正常工作
以下是我用来呈现表单的代码...但是什么也没有。
<Col lg="5">
<Card className="bg-secondary shadow border-0">
<CardBody className="px-lg-5 py-lg-5">
<Form role="form">
<FormGroup className="mb-3">
<InputGroup className="input-group-alternative">
<InputGroupAddon addonType="prepend">
<InputGroupText>
<i className="ni ni-email-83" />
</InputGroupText>
</InputGroupAddon>
<Input placeholder="Email" type="email" name="emailAddress" invalid />
</InputGroup>
<FormFeedback>This bollocks is not showing!!!!</FormFeedback>
</FormGroup>
<div className="text-center">
<Button className="my-4" color="primary" type="button">Submit</Button>
</div>
</Form>
</CardBody>
</Card>
</Col>
有人在显示表单反馈方面有任何困难吗?
答案 0 :(得分:1)
FormFeedback块必须与Input块在同一父级中才能正常工作,通过将属性添加到输入无效,最好将其标记为当输入无效时应显示它,例如:
<Col lg="5">
<Card className="bg-secondary shadow border-0">
<CardBody className="px-lg-5 py-lg-5">
<Form role="form">
<FormGroup className="mb-3">
<InputGroup className="input-group-alternative">
<InputGroupAddon addonType="prepend">
<InputGroupText>
<i className="ni ni-email-83" />
</InputGroupText>
</InputGroupAddon>
<Input
placeholder="Email"
type="email"
name="emailAddress"
invalid={type invalid condition here!} />
<FormFeedback invalid>This bollocks is not showing!!!!</FormFeedback>
</InputGroup>
</FormGroup>
<div className="text-center">
<Button className="my-4" color="primary" type="button">Submit</Button>
</div>
</Form>
</CardBody>
</Card>
</Col>
答案 1 :(得分:0)
您需要将“ FormFeedback”移到“ InputGroup”中,然后它才能工作。