Posts

Showing posts from January, 2024

Mastering Email Validation in JavaScript with onchange Event: A Comprehensive Guide

  Mastering Email Validation in JavaScript with onchange Event: A Comprehensive Guide <input type="email" id="emailInput" onchange="validateEmail()"> <span id="emailError" style="color: red;"></span> <script> function validateEmail() { const emailInput = document.getElementById("emailInput"); const emailError = document.getElementById("emailError"); const emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; if (!emailPattern.test(emailInput.value)) { emailError.textContent = "Invalid email format"; } else { emailError.textContent = ""; } } </script>

Use EJS as Template Engine in Node.js Use EJS as Template Engine in Node.js Use EJS as Template Engine in Node.js

  Use EJS as Template Engine in Node.js Use EJS as Template Engine in Node.js Use EJS as Template Engine in Node.js Use EJS as Template Engine in Node.js  /////////////////////////////// //////////////////////////////////////////// command line npm install ejs etemp.js // Set express as Node.js web application // server framework. // To install express before using it as // an application server by using // "npm install express" command. const express = require ( 'express' ); const app = express (); // Set EJS as templating engine app . set ( 'view engine' , 'ejs' ); app . get ( '/' , ( req , res ) => {       // The render method takes the name of the html     // page to be rendered as input.     // This page should be in views folder       // in the root directory.     let data = {         name : 'Akashdeep' ,         hobbies : [ 'playing football' , 'playing che...

how to create node js page with html

///////////////command line install for express////////////// ////////////express.js////////////// const express = require ( 'express' );  npm install express   const app = express ( '' ); app . get ( '' ,( req , res ) => { res . send ( 'Hello,this is home page' ); }); app . get ( '/about' ,( req , res ) => { res . send ( 'hello this is about page' ); }); app . listen ( 5000 ); run with command PS C:\Users\dell\desktop\node-tut> node .\express.js run in web http://localhost:5000/about v ar http = require ( 'http' ),     fs = require ( 'fs' ); fs . readFile ( './index.html' , function ( err , html ) {     if ( err ) {         throw err ;     }           http . createServer ( function ( request , response ) {           response . writeHeader ( 200 , { "Content-Type" : "text/html" });           response . write ( html );     ...