Hackerss.com is a community of amazing hackers

Hackerss is a community for developers, data scientitst, ethical hackers, hardware enthusiasts or any person that want to learn / share their knowledge of any aspect of digital technology.

Create account Log in

Posted on

Validar campos in Javascript

Validar campos - Javascript:

//function to validate fields
function validateFields(name, email, password) {
  //validate name
  if (name.length < 3) {
    return false;

  //validate email
  if (email.indexOf("@") === -1) {
    return false;

  //validate password
  if (password.length < 6) {
    return false;

  //return true if all fields are valid
  return true;

const result = validateFields("John", "[email protected]", "123456");

console.log(result); //true
Enter fullscreen mode Exit fullscreen mode

Top comments (0)