JSFiddle - React, Tailwind, and code Playground

by savinkumarn

HTML

<!DOCTYPE html>
<html>
<body>

<form id="frm1" action="/action_page.php">
  Enter your Name:
        <input type="text" name="name" autocomplete="off" placeholder="Name">
        <br/>
        Enter Your Password:
        <input type="password" name="password" autocomplete="off" placeholder="password">
        <br/>
        Enter Your Age:
        <input type="number" name="age" autocomplete="off" placeholder="age">
        <br/>
        Enter Your Gender: Male:
        <input type="radio" name="gender" value="M" /> FeMale:
        <input type="radio" name="gender" value="F" />
        <br/>
        Enter Your Date Of Birth:
        <input type="date" name="dob" autocomplete="off" placeholder="mm/dd/yyyy">
        <br/>
        <select name="Country">
            <option value="IN" selected>India</option>
            <option value="US" >USA</option>
            <option value="UK" >UK</option>
        </select>
        <input type="submit" value="login" onclick="sample()">
</form> 

<p>Click "Try it" to display the value of each element in the form.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>
</body>
</html>

JavaScript

function sample() {
    alert("Hello there!");
    var x = document.getElementById("form1");
    var i;
    for (i = 0; i < x.length; i++) {
        document.write(x.elements[i].name);
        document.write("<br/>");
        document.write(x.elements[i].value);
        document.write("<br/>");
    }
}