Is there a way to disable typing/pasting into the date input and only allowing users to select from the date picker in AntD?

时光怂恿深爱的人放手 提交于 2020-01-15 08:38:25

问题


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.


回答1:


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>
    );
  }


来源:https://stackoverflow.com/questions/58854765/is-there-a-way-to-disable-typing-pasting-into-the-date-input-and-only-allowing-u

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!