Hi ! This is my first challenge with JS. I just have an issue. When I submit the form with empty fields, the error messages are displayed but when I try to submit the form again, with filled fields, the error messages remain displayed. Do you know how I can fix this ? Thank you :)
Peter Bujaky
@peterbujakyAll comments
- @loicsolbesSubmitted almost 2 years ago@peterbujakyPosted almost 2 years ago
Hi soles!
Try this:
In your function "ValidateEmail(input, el)",
instead of:
if (input.value.match(validRegex)) { return true;}
use:
if (input.value.match(validRegex)) { input.value =""; el.textContent=""}
<------ This clears the input field and the error message.and in your other function do the same with an else statement at the end:
function isEmpty(inputElement, element, message, label) { if(!inputElement.value) { inputElement.style.borderColor = 'hsl(0, 100%, 74%)'; element.textContent =
${message} cannot be empty
styling(label) }else { inputElement.value = ""; element.textContent = ""; }
}Following the same logic you can reinstate the default styles and remove the red border.
I hope this helps! Great job with the functions by the way!
Marked as helpful0 - @YinkajaySubmitted about 2 years ago
Kindly review and test out. Cheers!
@peterbujakyPosted about 2 years agoHi! Great job! I would just use the radial gradient (ellipse at top) css function to make the background color transition from a ligher shade to dark.
Marked as helpful1