In the process of creating a basic login form using HTML and CSS, I'm incorporating Javascript to handle empty field validations.
To view my current progress, you can find my code on jsfiddle
My goal is to implement validation for empty text fields within the form and show error messages directly below each textbox using CSS and HTML.
The CSS code looks like this:
.validation
{
color: red;
margin-bottom: 20px;
}
As for the Javascript snippet:
$("#txtUsername").parent().after("<div class='validation' style='color:red;margin-bottom: 20px;'>Please enter username</div>");
I'm referencing a similar solution from this question, but for some reason, it's not functioning as expected.
Could anyone offer assistance?
Thank you in advance.