forms icon indicating copy to clipboard operation
forms copied to clipboard

netteForms.js: Set validation result CSS classes

Open hranicka opened this issue 9 years ago • 3 comments

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.

hranicka avatar Feb 18 '15 21:02 hranicka

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

fprochazka avatar Feb 18 '15 21:02 fprochazka

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.

hranicka avatar May 23 '15 17:05 hranicka

@hranicka Could you please rebase it? I like an idea. Is there any reason to not to merge it @dg?

f3l1x avatar Jun 18 '17 12:06 f3l1x