Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

90
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!