slip 1:FSD-I

 Create an HTML form for Login and write a JavaScript to validate email ID and Password using Regular Expression. 



<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script>
        let validation=()=>{
            let isvalid=true;
            var emailV=document.getElementById("email").value.trim();
            var password=document.getElementById("password").value.trim();

            document.getElementById("emailError").innerText="";
            document.getElementById("password").innerText="";

            let regEmail=/^[a-z0-9._-]+@[a-z]+\.[a-z]{2,3}$/;
            let regPassword=/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).{6,}$/

            if(!regEmail.test(emailV)){
               document.getElementById("emailError").innerText="Enter the valid email";
               isvalid=false;
            }
             if(!regPassword.test(password)){
               document.getElementById("passwordError").innerText="Enter the valid password";
               isvalid=false;
            }
            if(isvalid){
                alert("Form succesfully submit");
            }
            return isvalid;
        }
    </script>
    <title>Login form</title>
</head>
<body>
    <form align="center" style="border:2px solid black; padding: 20px;" onsubmit="return validation()">
        <h2>Login</h2>
        <label>Name</label>
        <input type="text" id="name" placeholder="Enter the name"/><br>
        <br>
        <label>Email</label>
        <input type="text" id="email" placeholder="Enter the email"/><br>
        <span id="emailError"></span><br>
        <label>Password</label>
        <input type="password" id="password" placeholder="Enter the password"/><br>
        <span id="passwordError"></span><br>
        <button type="submit">Submit</button>
    </form>
</body>
</html>

Comments

Popular posts from this blog

Slip 11: Write node js application that transfer a file as an attachment on web and enables browser to prompt the user to download file using express js.

Slip 7 Create a node js file named main.js for event-driven application. There should be a main loop that listens for events, and then triggers a callback function when one of those events is detected.

Slip 1(a) Write an Angular 13 application addition of two numbers using ng-init, ng-model & ng-bind. And also demonstrate ng-show, ng-disabled, ng-click directives on button component.