christianalfoni/formsy-react

valid="" and onSubmitValid submits missing unvalided data

jcalfee opened this issue · 4 comments

Note: an optional password is unusual but needed. Is actually a passphrase for another private mnemonic phrase..

So, I needed to add value="" to password and confirm to allow an empty password submission.

This causes a problem however. If I type something short in the 1st password and press enter quickly, the 1st password field the form will submit even though the password confirm is empty and does not match. Additionally, it submits an empty password...

If I wait a second before pressing enter, the error appears and it works as expected.

<Form onValidSubmit={this.submit}>
            <Input type="password" name="password" id="password"
              label="Passphrase" value="
              placeholder="Password"
              componentRef={component => {
                this.passwordRef = component
              }}
            />

            <Input
              type="password" name="confirm" label="Confirm"
              value=""
              placeholder="Confirm"
              validations="equalsField:password"
              validationErrors={{
                equalsField: 'Passwords must match.'
              }}
            />
</Form>

I'll attempt to enhance the validation and see if I can do this without value=""..

Shouldn't validations="equalsField:password" pass when the password and confirmation are empty and not required? See bip0039.

Looks pretty serious... I can't reliable get the password field value when I submit via Enter..

Is the <Input > that you're using from formsy-react-components? If so, is it from the alpha?

yes and yes.. Sorry I though it was just wrapping. I'm retesting.. thank you