Design comparison
Solution retrospective
How to get red border on wrong entry, also why my email validation is not working? kindly help!
Community feedback
- @manojks092Posted almost 3 years ago
Hey there, if you want to input to turn red or any other color when incorrect, then use outline property in javascript. Like this :
inputElement.style.outline = " 2px solid red"
; PS: here inputElement is the reference to the form input element , can be for password or text. Hope you'll find it helpful. Happy coding :DMarked as helpful0 - @skyv26Posted almost 3 years ago
Lol! you instead of using Match Regex you directly compare it with the String
if(email_add == "/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/"){ setTimeout(() => { document.getElementById("email-error").style.display = "none"; }, 3000); document.getElementById("email-error").style.display = "block"; }
Above is wrong
if(email_add.match(/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/){ setTimeout(() => { document.getElementById("email-error").style.display = "none"; }, 3000); document.getElementById("email-error").style.display = "block"; }
Now it is correct. Update your code and recheck again.
There are other problems too. I think you have to go through again from your CSS and JS too.
Good Luck
Marked as helpful0@mahnoork18Posted almost 3 years ago@skyv26 I think the responsive part is fine, but I do want input to turn red when an entered element is incorrect. yes, I do have some work on js part thanks for the suggestion.
1
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord