question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Validations not working in 0.5.2

See original GitHub issue

Validations stopped working when I upgraded from 0.5.1 to 0.5.2. My form looks like this, when I comment out validations, everything works. Without validations, no cigar. Any ideas?

<Formsy.Form
              ref="form"
              className="form"
              onValid={() => this.enableLoginButton()}
              onInvalid={() => this.disableLoginButton()}
              onValidSubmit={(model) => this.login(user, model)}>
              <FormsyText
                name="email"
                floatingLabelText="Email Address"
                fullWidth
                // validations="isEmail"
                // validationError="Please enter a valid email address"
                {...textFieldStyles}
                required
              />

              <FormsyText
                name="password"
                type="password"
                floatingLabelText="Password"
                // validations={{ minLength: 6 }}
                // validationError="Password must contain at least 6 characters"
                fullWidth
                {...textFieldStyles}
                required
              />```

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:31

github_iconTop GitHub Comments

3reactions
joelkozcommented, Oct 26, 2016

I am seeing this also. It has to do with any validations, including “required.” The culprit seems to be line 81 of FormsyText.js, where a "this.resetValue() is called if the field is not valid. This results in weird behaviors such as:

  1. If you have a validation like “isEmail”, and the initial value of the field is blank, typing ANYTHING will be ignored (as the first character is not a valid email address, so the field is reset).
  2. If you have a field marked as “required” and the initial value HAS data and you start backspacing over it, you can remove all but the first character. Once you remove the first character, it becomes “invalid”, it resets, and the old value is put back in place.

I commented out that line in the lib/FormsyText.js of my node_modules dir, and it now seems to be behaving. I don’t know enough about the code to determine if that is a valid fix or just a band-aid.

2reactions
rojobuffalocommented, Nov 21, 2016

Thanks @codeaholicguy. Just published 0.5.3

Read more comments on GitHub >

github_iconTop Results From Across the Web

bootstrap validate input type file not working - Stack Overflow
I'm having trouble getting a bootstrap validation for an input type of 'file' to work. The form is validating even if I do...
Read more >
Is there a way to disable the schema validation typo detection ...
I have a 'help' field which I use to describe the field because at some point I intend to use eve-docs to describe...
Read more >
Bootstrap Validator not working - MSDN
User-1499457942 posted. Hi. I am using Bootstrap Validator but it is not working $(document).ready(function() { $('#BookCategoryForm').
Read more >
Form Validation: You want :not(:focus):invalid, not - Bram.us
The problem is caused by a piece of CSS similar to this snippet: .error-message { display: none; } input:invalid { border-color: ...
Read more >
Updates - FormValidation
The best validation library for JavaScript. No dependency. Supports popular frameworks including Bootstrap, Zurb Foundation, Pure, Semantic, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found