Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

How can masked input be cleared #12

@BotOfTheBots

Description

@BotOfTheBots

As header states i do not find any way to clear masked input.

This works:

const React = require('react')
const MaskedField = require('react-masked-field');

class MaskedInput extends React.Component {

  componentWillReceiveProps(nextProps){
    if(!nextProps.value)
      this.refs.inputElement.setState({value: ""})
  }

  render() {
    return (
      <MaskedField
        ref="inputElement"
        id={"date-from"}
        mask="2999-19-39"
        translations={{'1': /[0-1]/, '2': /[1-2]/, '3': /[0-3]/, '9': /[0-9]/}}
        placeholder="date from"
        onComplete={this.props.selectDateFrom}
        onBlur={this.props.validateDate}
      />
    )
  }
}

module.exports = MaskedInput;

The way that it hides the value and it looks like it was cleared but when input is clicked again the old value shows up. Is it possible to clear masked input programmatically?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions