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.

Don't validate onSubmit

See original GitHub issue

Current Behavior

Can not determine if validate was fired from blur, change, or handleSubmit

Desired Behavior

detect what event fired validate

Suggested Solutions

pass a flag that says what event fired validate

Info

I need the ability to tell if validate was fired from handleSubmit so I can only validate onChange and onBlur. Is there a way to do this currently?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

25reactions
conatuscommented, May 23, 2018

Thanks very much for working on Formik. It’s a great library.

However this functionality is something we would like and is not quite a duplicate of #126. We would like to be able to tell the difference between a validation that is the result of a blur or change and a validation that is the result of a submit.

This is because with a on submit validation failure we want to be able to scroll the user to the invalid field, while on blur and change we want to display the error and not run anything around scrolling. Currently I cannot work out a way to do this without a significant and ugly hack, so would appreciate this feature.

18reactions
jaredpalmercommented, Jan 26, 2018

Validation is always run on submit.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I disable validation on submit?
I have a workaround for you: Just remove the validation Schema, validateOnMount, validateOnBlur because we are going to handle them ...
Read more >
useForm - handleSubmit
This function will receive the form data if form validation is successful. ... It can be invoked remotely as well handleSubmit(onSubmit)(); // You...
Read more >
Validation
Form-level validation is useful because you have complete access to all of your form's values and props whenever the function runs, so you...
Read more >
How to stop form submission using JavaScript?
<form onsubmit="return false;"> //content of form tag </form> ... In this method we do not need to use the onsubmit event instead we...
Read more >
Batch validation
Batch validation checking typically operates from the onsubmit event ... />I do not agree <br> <input type="reset" /> <input type="submit" /> </form>.
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