Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

form-validation #49

Open
roshlarosh opened this issue Dec 13, 2019 · 0 comments
Open

form-validation #49

roshlarosh opened this issue Dec 13, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@roshlarosh
Copy link

You can implement some form validation by applying existing method: validity.valueMissing
you can either have a separate file with all the form validation or have it in your index.js file

const username = document.getElementById("new-username");
const userErr = document.getElementById("userErr");

let checkUser = () => {
  if (username.validity.valueMissing) {
    displayErr(userErr, "Please enter a username");
  } else {
    displayErr(userErr, "");
    return true;
  }
};
function displayErr(errElem, errMsg) {
  errElem.innerText = errMsg;
}

username.addEventListener("focusout", checkUser);
@roshlarosh roshlarosh added the enhancement New feature or request label Dec 13, 2019
@pat-cki pat-cki self-assigned this Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants