Chrome Extension

Enter only number field validation redux form

You can apply the number-only input field validation by creating a function that can check if the given value is a number or not.
const numberValidator = value => value && isNaN(Number(value)) ? 'Must be a number' : undefined

<Field 
    name="totalScore" 
    type="number"
    component={renderField}
    label="Total Score"
    validate={[ numberValidator ]}
/>
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool
Was this helpful?
0 Comments