From 158c137d9867bc8e404b8f1ff9be884049ffb621 Mon Sep 17 00:00:00 2001 From: Vraj Mevawala <147795720+vrajmevawala@users.noreply.github.com> Date: Sat, 4 Apr 2026 14:05:50 +0530 Subject: [PATCH 1/2] Initialize Express app with form validation --- index1.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 index1.js diff --git a/index1.js b/index1.js new file mode 100644 index 0000000..aef9407 --- /dev/null +++ b/index1.js @@ -0,0 +1,50 @@ +const express = require("express"); const path = require("path"); + +const Joi = require("joi"); +const bodyParser = require("body-parser"); + + +const app = express(); +app.use(bodyParser.urlencoded({ extended: true })); + + +// Serve HTML form +app.get("/", (req, res) => { +res.sendFile(path.join(__dirname, "views", "form.html")); +}); + + +// Validation schema using Joi +const facultySchema = Joi.object({ +facultyId: Joi.number().integer().positive().min(10).max(9999).required(), facultyName: Joi.string().min(2).required(), +mobile: Joi.string().pattern(/^[0-9]+$/).min(9).required(), age: Joi.number().integer().min(18).max(100).required(), +birthYear: Joi.number().integer().min(1920).max(2022).required(), address: Joi.string().required(), +email: Joi.string() +.pattern(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.(com|in|org|ai)$/) +.required() +}); + + +// Handle form submission +app.post("/submit", (req, res) => { +const { error, value } = facultySchema.validate(req.body); + + +if (error) { +return res.status(400).send(`
Faculty ID: ${value.facultyId}
+Name: ${value.facultyName}
+Mobile: ${value.mobile}
+Age: ${value.age}
+Birth Year: ${value.birthYear}
+Address: ${value.address}
+Email: ${value.email}
+`); +}); + + +const PORT = 3000; +app.listen(PORT, () => console.log(`Server running at http://localhost:${PORT}`)); From 937a8ee1ad1dae023f9a69d86ea5febfff6df2a4 Mon Sep 17 00:00:00 2001 From: Vraj Mevawala <147795720+vrajmevawala@users.noreply.github.com> Date: Sat, 4 Apr 2026 14:59:21 +0530 Subject: [PATCH 2/2] Add GreetingCard component to display a greeting --- check.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 check.js diff --git a/check.js b/check.js new file mode 100644 index 0000000..a1811f1 --- /dev/null +++ b/check.js @@ -0,0 +1,19 @@ +import React from "react"; + +function GreetingCard() { + const name = "John"; + const date = new Date().toLocaleDateString(); + + return ( +Welcome to our website.
+Today is {date}
+ +