admin管理员组文章数量:1335371
I have this datepicker below. How can I save the value of the input date the user chooses in a const so that I can later use? I apologize if the question is beginner-ish.
import React from 'react'
import { Form } from 'react-bootstrap';
class BootstrapDate extends React.Component{
render(){
return(
<div>
<div className="row">
<div className="col-md-12">
<Form.Group controlId="duedate">
<Form.Control type="date" name="duedate" placeholder="Due date" />
</Form.Group>
</div>
</div>
</div>
)
}
}
export default BootstrapDate;
I have this datepicker below. How can I save the value of the input date the user chooses in a const so that I can later use? I apologize if the question is beginner-ish.
import React from 'react'
import { Form } from 'react-bootstrap';
class BootstrapDate extends React.Component{
render(){
return(
<div>
<div className="row">
<div className="col-md-12">
<Form.Group controlId="duedate">
<Form.Control type="date" name="duedate" placeholder="Due date" />
</Form.Group>
</div>
</div>
</div>
)
}
}
export default BootstrapDate;
Share
asked Mar 1, 2021 at 21:19
chr0sychr0sy
811 gold badge1 silver badge6 bronze badges
1 Answer
Reset to default 2Just add a Value and Onchage Method in Form.Control
import "./styles.css";
import Form from "react-bootstrap/Form";
import { useState } from "react";
export default function App() {
const [date, setDate] = useState(new Date());
console.log("DATE", date);
return (
<div className="App">
<div>
<div className="row">
<div className="col-md-12">
<Form.Group controlId="duedate">
<Form.Control
type="date"
name="duedate"
placeholder="Due date"
value={date}
onChange={(e) => setDate(e.target.value)}
/>
</Form.Group>
</div>
</div>
</div>
</div>
);
}
本文标签: javascriptHow to get value of FormControlReact Bootstrap Date PickerStack Overflow
版权声明:本文标题:javascript - How to get value of Form.Control - React Bootstrap Date Picker? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742263349a2442927.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论