Search code examples
twitter-bootstrapreactjsreact-day-picker

Is it possible to set input field of react-day-picker as required?


I have two DayPickerInput fields in a form and would like to mark them as required field but don't know how. Can anybody please help?

        <FormGroup row>
            <Col md="4">
                <Label htmlFor="begin">Begin</Label>
            </Col>
            <Col xs="12" md="8">
                <DayPickerInput value={this.state.begin}
                                format={settings.formatDate} />
            </Col>
        </FormGroup>
        <FormGroup row>
            <Col md="4">
                <Label htmlFor="end">End</Label>
            </Col>
            <Col xs="12" md="8">
                <DayPickerInput value={this.state.end}
                                format={settings.formatDate} />
            </Col>
        </FormGroup>

UPDATE: I tried with inputProps:

<DayPickerInput inputProps={required} />

but got error:

ReferenceError: required is not defined

Solution

  • I tried with inputProps:

    <DayPickerInput inputProps={required} /> 
    

    but got error:

    ReferenceError: required is not defined
    

    This is how to pass object as prop:

    <DayPickerInput 
       inputProps={
         { required: true }
       } 
    />