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

214
Views
How can I get a alert saying "Welcome" +username that I entered

So,here's my index.html file which consists of username and password input fields.So,when the user clicks on the submit button I want to get a alert saying "Welcome"+username.Im using nodejs also here. please help me.

index.html

<body>     
<main class="form-signin">
    <form method="post" action="/">
      <h1 class="h3 mb-3 fw-normal">Login</h1>
      <br/>
  
      <div class="form-floating ">
        <input type="name" class="form-control" name="username"  placeholder="Enter Username...">
        <label for="floatingInput">Username</label>
      </div>
      <div class="form-floating">
        <input type="password" class="form-control" name="password" placeholder="Enter password">
        <label for="floatingPassword">Password</label>
      </div>
      <button class="w-100 btn btn-lg btn-primary" type="submit">Sign in</button>
    </form>
  </main>
</body>

Here's my server.js file where all the routes has been handled. So below here when i click the submit button im getting the value of username entered in post request But how exactly should I create an alert?

server.js

const express = require("express");
const bodyParser = require("body-parser");
const app = express();

app.use(express.static("public"));

app.use(express.json());
app.use(express.urlencoded({
    extended: true
}));

app.get('/', function(req, res) {
    res.sendFile(__dirname+"/index.html");
});

app.post('/', function(req,res) {
   var username=req.body.username;

    // I don't know what to do here exactly
});

app.listen(3000,() => {
    console.log("Server started on port 3000");
});
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!