Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

91
Vistas
DB adding characters on Inputs

I have a form on the client side in which I send data (username and password) to my DB through a socket event:

CLIENT:

     export default function RegisterForm() {
  const [user, setUser] = useState("");
  const [password, setPassword] = useState("");
  const navigate = useNavigate();

  const handleSubmit = () => {
    socket.emit("newuser", { user, password });

    navigate("/");
  };

  return (
    <>
      <div className="join-container">
        <header className="join-header">
          <h1>
            <i className="fas fa-smile"></i> Registration Page
          </h1>
        </header>
        <main className="join-main">
          <form action="chat.html">
            <div className="form-control">
              <label htmlFor="username">Username</label>
              <input
                type="text"
                name="username"
                id="username"
                value={user}
                onChange={(e) => setUser(e.target.value)}
                placeholder="Set username..."
                required
              />
            </div>
            <div className="form-control">
              <label htmlFor="password">Password</label>
              <input
                type="password"
                name="password"
                id="pasword"
                value={password}
                onChange={(e) => setPassword(e.target.value)}
                placeholder="Set new password..."
                required
              />
            </div>
          </form>
          <button type="submit" className="btn" onClick={handleSubmit}>
            Submit
          </button>
        </main>
      </div>
    </>
  );
}

SERVER:

socket.on("newuser", async (msg) => {
    try {
      Users.create({
        username: msg.user,
        password: msg.password,
      });
    } catch (err) {
      console.log(err);
    }
  });

DB MODEL:

const Users = db.define("users", {
  username: {
    type: DataTypes.STRING,
    allowNull: false,
  },
  password: {
    type: DataTypes.STRING,
    allowNull: false,
  },
});

The problem is that when I submit the password, it stores blanck carachters. For example If "1234" password is submited, on the DB I see "1234----------"

"-" are blank spaces

What could be the problem?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda