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 ]}
/>
Code faster with devsheet chrome extension and increase productivity as a programmer
search code from your favorite search engine instantly.
Install Now
Was this helpful?
0 Comments
Open Code Manager We are hiring