Skip to content

Instantly share code, notes, and snippets.

@TheGarkine
Created April 9, 2022 22:16
Show Gist options
  • Select an option

  • Save TheGarkine/e26d87290634d1f63c994b58fb1d95ab to your computer and use it in GitHub Desktop.

Select an option

Save TheGarkine/e26d87290634d1f63c994b58fb1d95ab to your computer and use it in GitHub Desktop.
const form = document.getElementById("contactForm");
if (request.status === 200) {
// Freeze the form
document.getElementById("contactEmail").readOnly = true;
document.getElementById("contactMessage").readOnly = true;
document.getElementById("contactSubmit").disabled = true;
// Append a thank you message
const span = document.createElement("span");
span.innerHTML = "Thank you for your message!"
span.style.color="green";
form.appendChild(span);
} else {
// Append an error message
const span = document.createElement("span");
span.innerHTML = "An error occured please try again later!"
span.style.color="red";
form.appendChild(span);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment