Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation plugin tires to validate all enabled elements #20

Open
farrukhsubhani opened this issue Jan 26, 2013 · 4 comments
Open

Validation plugin tires to validate all enabled elements #20

farrukhsubhani opened this issue Jan 26, 2013 · 4 comments

Comments

@farrukhsubhani
Copy link

When a step is active most of the time its just that step that needs to be validated so you can change the line

$($step.find(':input:enabled').get().reverse()).each(function ()

to read

$($step.find(':input:enabled').not(":hidden").get().reverse()).each(function ()

This will only validate visible elements and not hidden steps. If you want more flexibility add a flag to properties for validatehidden:false and if someone wants that function they can set it to true (but i cant see any point of validating hidden fields)

@wbotelhos
Copy link
Owner

Hi @farrukhsubhani,

Stepy validates the hidden fields because you can click to jump 3 step ahead, then all steps behind, that is hidden, should be validate to be continue.

Maybe we can just validates hidden fields, in that case when is possible jump steps by title click.

@farrukhsubhani
Copy link
Author

Most ruby and mvc asp.net framework generate a hidden field for checkboxes and using jquery validation plugin we can put in ignore case however in stepy the above line takes all enabled inputs. I have changed it to use opt.ignore string to respect ignore option. Which is same for validation plugin as well.

@wbotelhos
Copy link
Owner

I have an anger about jQuery Validation about the hidden validation by default.
It causes a issue on Stepy, because we need what a told you: Validate hidden fields when we jump more than on stepy. I did a hack to avoid that default, but my intention is create the jQuery Validaty and integrates it on future.

@farrukhsubhani
Copy link
Author

Thinking about jumping more than one step and validating whole form. You can have an option flag in opt.vaidateall when true will not filter the fields.

There are two things here. 1. Validating fields and 2. Missing a step by jumping more than one.

If you seperate these two concerns then its easy to see why validation is actually not needed on hidden fieds.

For example you have steps array which you can also have step.status for each step as a property. Initialize it to 0. When you make your step visible you dont need to set it to anything. But when someone jumps to another step you can mark the leaving step as -1 if invalid and 1 if valid and check if the last step index is current index - 1 then its not a jump else loop through all step indexes in between and mark them as -1 because they were skipped.
You can also use a status array like

  • seen / visited
  • not seen
  • valid
  • skipped
  • invalid

All of these can have css classes to be set or not to reflect step status.

This way you only rely on jquery validation when required. Let me know if you think the approach is not right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants