0

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.

3
  • Are you using precompiled SASS (like with SimpLESS or Scout), or something like sass.js to compile / interpret the SASS on demand? Commented May 22, 2013 at 19:31
  • 3
    Sass knows nothing about the DOM or anything about your document, it only compiles to CSS. CSS does have psuedo classes like :required or :invalid. Commented May 22, 2013 at 20:47
  • There's an answer in another question regarding this method: stackoverflow.com/a/8695114/1384441 Commented May 23, 2013 at 9:39

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.