How to display error message when your input field is empty using js and css.
.you can create a function to display errors.
eg.
Function displayError (e) {
e.preventDefault();
//iterate over all input field using for each method
// css part
//the class “error_message” that was added in js will be styled in the css file.
.error{
border: 2px solid var(- -Red);
}
.error_message : :after {
content: “Kindly fill in valid card details “;
color: var(- -Red);
margin-top: .2rem;
}
How to display your input on real time using JavaScript.
.You can create a function to display input in real time
eg
Function displayInRealtime (){
.Target all your input field using “class” or “id”
eg
const cardNumber = document.getElementById(“number”);
.Attached h#the class using the “textContent” property.
.Also target the span or areas you going to display the text gotten from the input field and attach to the “.value” property.
eg
cardNumber.text content = document.querySelector(“.display-number”).value;
};
I have been battling with my code, trying to figure our why it is not working and i just realized i didn’t add my js file to my html. This shit is fustrating as f 😫😭😭😭