- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Maybe some frist-class idiot manager decided that using CSS was a strict requirement, and then didn't bother (or was incapable of) checking that it was used in a sane way.
Admin
Get rid of it little by little.
Page after page, remove the class that is detected by jQuery, and hard-code the asterisk in the HTML. When there is no use of jQuery anymore, remove jQuery.
And during code reviews, roast whoever adds more uses of that bad code.
Admin
"Sean" is probably a pseudonym, but in the event it's not, it sounds like a former co-worker. If it is, good luck with this one, old friend! But then, wait a month and you'll have another client with another mess just like this one.
The struggle continues.
Admin
Or just use CSS content ::after...
Admin
Inputs don't have ::before and ::after, IIRC. (At least not all of them.) They do have a required attribute since HTML 5, though.
Admin
The change from an mandatory input to an optional and the other way around results often in a major business logic change. Even if you have a very dumb terminal client there might be logic that actually changes on the client-side beyond a simple representation change, so in practice you have to check the usage of the input everywhere because it is basically a type change - turning an non-nullable type into a nullable type. And we all know that in proper null handling is still one of the biggest sins bad developers do. Oh and before anyone response with "Javascript is typeless" - yes, that means the responsibility of ensure the correct business case is on the developer without the safety net for the language preventing you from invalid usage, so it is even more work on the developer side. I guess a lot of inexperience developers are not aware of this, resulting in the big pile of bad Javascript code we have these days.
Admin
I guess, this may be well how this started. They intended to use a
::before
or::after
pseudo-element on theinput
element and found that they couldn't do it. So probably in some existential despair, they decided to fix this up in JS. (Well, they didn't really do so, rather using JQuery for no reason.) For this, they moved the class name to a newly introduced span to provide an anchor for the JQuery call. Busily fixing the fix, they totally missed that at this point they could have had inserted a plain asterisk as well…(Also, as indicated, this is allegedly old code, so this may have been before the
required
attribute was reliably a thing.)Admin
PS:
Or it may have been still close to the requirements. At least, they were doing as intended, just by "a little help" by JQuery. Still, the result (and even the flow) is somewhat close to what would have been achieved using pure CSS.