Search code examples
redux-form

redux-form, submit form with an error


I have a form, and on one field I want to show a validation error (as an information for a user) but I don't want this error to prevent submitting the form.

I would appreciate any hint, how to do this...

---EDIT---

I was asked to provide an example. Please use as an example this provided by redux-form: http://redux-form.com/6.6.1/examples/fieldlevelvalidation/

<Field name="username" type="text"
    component={renderField}
    label="Username"
    validate={[ required, maxLength15 ]}
/>

Here are 2 validate functions: required and maxLength15. I would like to allow user submit the form even if the maxLength15 returns the error message. I want to show the message but allow the form submit


Solution

  • If you want to be able to submit, then you should use warnings instead of error. redux-form won't let you submit it otherwise.

    To do this using field-level validations, you can simply change the validate prop with the warn prop:

    <Field name="username" type="text"
        component={renderField}
        label="Username"
        warn={[ required, maxLength15 ]}
    />