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

netteForms.js: Set validation result CSS classes #64

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hranicka
Copy link
Contributor

Sometimes it's useful visually distinguish valid/invalid inputs.

We use something like the code in this PR.
When we need to use another CSS classes or something absolutely different, it's possible redefine Nette.markControlValid and Nette.markControlInvalid.

But I don't know if the PR should be accepted.
Also without it we can redefine Nette.validateControl, call original backed-up function and handle the result.

So most likely this will be closed without merge.
But I can try it and listen your opinions.

@fprochazka
Copy link
Contributor

I like it. Best part is you've essentialy created hooks that can be overriden with custom functions.

return true;
};


Nette.markControlValid = function(elem) {
Nette.switchClass(elem, 'control-invalid', 'control-valid');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have nette namespace.

@dg dg force-pushed the master branch 2 times, most recently from 131f7d2 to 532059a Compare May 21, 2015 11:49
@hranicka
Copy link
Contributor Author

This PR should be without any BC break.

Adds CSS classes according to validation result of each control.

Classes are prefixed with nette-* and should be compatible with applications using netteForms.js (thx @Majkl578 ).

Functions can be overridden with custom ones (Nette.markControlValid, Nette.markControlInvalid, Nette.switchClass).

So with this, on target system we can easily style valid/invalid form controls or add custom code executed for validation results.

@dg dg force-pushed the master branch 2 times, most recently from a57a557 to 55d0eb8 Compare June 19, 2015 12:05
@dg dg force-pushed the master branch 2 times, most recently from 9e359e6 to fa84d63 Compare April 5, 2016 23:23
@dg dg force-pushed the master branch 2 times, most recently from 3c1619a to 31bc0a3 Compare April 11, 2016 01:44
@dg dg force-pushed the master branch 7 times, most recently from 6b04b51 to d1c30d6 Compare April 21, 2016 13:03
@dg dg force-pushed the master branch 5 times, most recently from fd381fb to b70e5da Compare May 19, 2016 00:28
@dg dg force-pushed the master branch 2 times, most recently from c996b4c to c8f4f95 Compare June 1, 2016 18:14
@dg dg force-pushed the master branch 4 times, most recently from 49c38f3 to c6f98c1 Compare April 1, 2024 01:05
@dg dg force-pushed the master branch 4 times, most recently from 337f707 to 2146e59 Compare May 2, 2024 10:56
@dg dg force-pushed the master branch 6 times, most recently from 94f43f0 to fe374c5 Compare May 12, 2024 13:07
@dg dg force-pushed the master branch 7 times, most recently from cb844f0 to 1d8a434 Compare August 8, 2024 14:36
@dg dg force-pushed the master branch 2 times, most recently from 479185b to 8da5796 Compare October 22, 2024 18:43
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

Successfully merging this pull request may close these issues.

4 participants