I'm trying to have different styles for whether a user has typed something into a text field or not. There doesn't seem to be a pseudo-class (like :hover or :focus) for this, but honestly, I'm not even sure how to google for it. I was thinking I could use an @if but im also not sure how to go about that. Any help would be great.
Asked
Active
Viewed 398 times
0
-
Are you using precompiled SASS (like with SimpLESS or Scout), or something like sass.js to compile / interpret the SASS on demand? – Jason M. Batchelor May 22 '13 at 19:31
-
3Sass knows nothing about the DOM or anything about your document, it only compiles to CSS. CSS *does* have psuedo classes like `:required` or `:invalid`. – cimmanon May 22 '13 at 20:47
-
There's an answer in another question regarding this method: http://stackoverflow.com/a/8695114/1384441 – chaenu May 23 '13 at 09:39
1 Answers
1
You can't do that with Sass (as cimmanon said), it's only a superset for css; you can only create rules for some pseudo-classes / cases.
You can validate fields with JavaScript or server-side languages - there are tons of plugins for almost any JS frameworks, and for vanilla JS also.
Just one example: https://github.com/posabsolute/jQuery-Validation-Engine

Marius Stuparu
- 474
- 3
- 14