I was tackling a challenge with signup form where I had to show custom error messages based on input validity-
Although I completed the challenge without ::after
element, it took me a whole day to find different ways to apply ::after
but at the end of the day, I decided to go the way I know and, leave it for another question on stackoverflow.
(From what I know) We can't add pseudo elements to input field with pure CSS. So I thought of adding it to field's parent Form-group. I found on searching through websites the .after()
method but it adds child node, not ::after
. Moreover, it keeps on adding elements each time I hit submit.
Then I thought of let errorMessage = $("#"+field.parentNode+"::after");
, but even before I could do something like errorMessage.css("content","Invalid message")
, it throws
unrecognized expression: #[object HTMLDivElement]::after
Now you know how screwed I was before deciding to go my simple way. Summed up everything, I just want to know the solution with ::after
if any! And also let me know if any of my above mentioned assumptions were wrong.
Here's my solution to this page.