Is there a way to disable typing/pasting into the date input and only allowing users to select from the date picker in AntD? disabling doesn't work either. I've gone through the documentation I tried this way
import { DatePicker } from 'antd';
...
handleDateChange = (e) => {
e.preventDefault();
}
...
render() {
...
<DatePicker onChange={this.handleDateChange} ... />
...
}
This way it just stopped taking input values even through picker panel.
Is there a way to disable typing/pasting into the date input and only allowing users to select from the date picker in AntD? disabling doesn't work either. I've gone through the documentation I tried this way
import { DatePicker } from 'antd';
...
handleDateChange = (e) => {
e.preventDefault();
}
...
render() {
...
<DatePicker onChange={this.handleDateChange} ... />
...
}
This way it just stopped taking input values even through picker panel.
Share Improve this question edited Nov 14, 2019 at 11:15 Federico klez Culloca 27.2k17 gold badges60 silver badges102 bronze badges asked Nov 14, 2019 at 10:38 Afaq Ahmed KhanAfaq Ahmed Khan 2,3022 gold badges31 silver badges41 bronze badges2 Answers
Reset to default 5please try with below prop
inputReadOnly={true}
For antd date picker, you need to set dispaly: none
in ant-calendar-input-wrap
class.
styles.css. (You just only need to add this css in your .css
file)
.ant-calendar-input-wrap {
display: none;
}
App.js
render() {
return (
<div className="App">
<DatePicker />
</div>
);
}