最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is there a way to disable typingpasting into the date input and only allowing users to select from the date picker

programmeradmin2浏览0评论

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 badges
Add a ment  | 

2 Answers 2

Reset to default 5

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论