Posts

Showing posts from October, 2024

long

Long 1.Create an HTML form that contain the Student Registration details and write a JavaScript to validate Student first and last name as it should not contain other than alphabets and age should be between 18 to 50. <!DOCTYPE html> <html> <head>     <title>Student Registration Form</title>     <script>         function validateForm() {             var firstName = document.forms["registration"]["firstName"].value;             var lastName = document.forms["registration"]["lastName"].value;             var age = document.forms["registration"]["age"].value;             var namePattern = /^[A-Za-z]+$/;             if (!namePattern.test(firstName)) {                 alert("First name must contain only alphabets.");    ...

Short

 Q1.Create a Node.js file that will convert the output "Hello World!" into upper-case Letters. // Create a new file called uppercase.js and add the following code // Define the string to be converted const originalString = "Hello World!"; // Use the toUpperCase() method to convert the string to upper-case const upperCaseString = originalString.toUpperCase(); // Log the original and converted strings to the console console.log(`Original String: ${originalString}`); console.log(`Upper-case String: ${upperCaseString}`); To run code: node uppercase.js Q2.Create a Node.js file that opens the requested file and returns the content to the client. If anything goes wrong, throw a 404 error // Create a new file called readFile.js and add the following code const http = require('http'); const fs = require('fs'); const url = require('url'); const port = 3000; // Create an HTTP server http.createServer((req, res) => {   // Get the requested file path f...