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;
}
//example
const result = validateFields("John", "[email protected]", "123456");
//output
console.log(result); //true
Top comments (0)