Create a Multi-Step Form in JavaScript

AmitDiwan
Updated on 06-May-2020 13:55:26

1K+ Views

To create a form with multiple steps, the code is as follows −Example Live Demo    * {       box-sizing: border-box;    }    body {       background-color: #f1f1f1;    }    #regForm {       margin: 100px auto;       font-family: Raleway;       padding: 40px;       width: 70%;       min-width: 300px;    }    h1 {       text-align: center;    }    input {       padding: 10px;       width: 100%;       font-size: 17px;       font-family:'Segoe ... Read More

Toggle Password Visibility with JavaScript

AmitDiwan
Updated on 06-May-2020 13:49:38

228 Views

To toggle between password visibility with JavaScript, the code is as follows −Example Live Demo Password visibility example Password: Show Password Click on the above checkbox to see your password as text    document.querySelector(".check").addEventListener("click", showPass);    function showPass() {       var inputPassEle = document.getElementById("inputPass");       if (inputPassEle.type === "password") {          inputPassEle.type = "text";       } else {          inputPassEle.type = "password";       }    } OutputThe above code will produce the following output −On checking the show password checkbox −

Trigger Button Click on Keyboard Enter with JavaScript

AmitDiwan
Updated on 06-May-2020 13:38:04

1K+ Views

To trigger a button click on keyboard "enter" with JavaScript, the code is as follows −Example Live Demo Trigger Button Click on Enter Example Button Press the "Enter" key inside the above input field to trigger the button.    var inputText = document.getElementById("inputField");    inputText.addEventListener("keyup", function(event) {       if (event.keyCode === 13) {          event.preventDefault();          document.getElementById("alertBtn").click();       }    }); OutputThe above code will produce the following output −On typing something in the field and then pressing enter −

Find Out If Caps Lock Is On in Input Field with JavaScript

AmitDiwan
Updated on 06-May-2020 13:34:32

215 Views

To find out if capslock is on inside an input field with JavaScript, the code is as follows −Example Live Demo    #textBox {       display: none;       color: red;    } Detecting Caps Lock Example Press caps lock in the above input field to check warning WARNING! Caps lock is ON.    var input = document.querySelector(".inputfield");    var textBox = document.querySelector(".textBox");    input.addEventListener("keyup", event => {       if (event.getModifierState("CapsLock")) {          textBox.style.display = "block";       } else {          textBox.style.display = "none";       }    }); OutputThe above code will produce the following output −On typing something in the input field with capslock on −

Check Whether a Checkbox is Checked with JavaScript

AmitDiwan
Updated on 06-May-2020 13:30:44

945 Views

To check whether a checkbox is checked with JavaScript, the code is as follows −Example Live Demo Displaying textBox when a checkbox is checked Checkbox: Checkbox is checked!!!    document.querySelector(".check").addEventListener("click", checkFunction);    function checkFunction() {       var checkBox = document.querySelector(".check");       var textBox = document.querySelector(".textBox");       if (checkBox.checked == true) {          textBox.style.display = "block";       } else {          textBox.style.display = "none";       }    } OutputThis will produce the following output −On clicking the checkbox −

Create Responsive Navigation Menu with Login Form Using HTML and CSS

AmitDiwan
Updated on 06-May-2020 13:14:18

548 Views

To create a responsive navigation menu with a login form inside of it, the code is as follows −Example Live Demo Document    body {       margin: 0px;       margin-top: 10px;       padding: 0px;    }    nav {       width: 100%;       background-color: rgb(39, 39, 39);       overflow: auto;       height: auto;    }    .links {       display: inline-block;       text-align: center;       padding: 14px;       color: rgb(178, 137, 253);     ... Read More

JavaScript ArrayBuffer IsView Method

AmitDiwan
Updated on 06-May-2020 12:37:53

231 Views

The ArrayBuffer.isView() method tells us if the passed parameter value is an ArrayBuffer view or not.Following is the code for ArrayBuffer.isView() method −Example Live Demo Document body {    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample {    font-size: 20px;    font-weight: 500; } JavaScript ArrayBuffer.byteLength property CLICK HERE Click on the above button to check the above value is array buffer view or not let fillEle = document.querySelector(".sample"); var buffer = new ArrayBuffer(8); var view1 = new DataView(buffer); view1.setInt16(0, 0x2721); fillEle.innerHTML = view1.getInt16(0).toString(16); document.querySelector(".Btn").addEventListener("click", () => {   ... Read More

JavaScript ArrayBuffer byteLength Property

AmitDiwan
Updated on 06-May-2020 12:35:34

135 Views

The byteLength property return the length of an ArrayBuffer in byte. Following is the code for ArrayBuffer.byteLength property −Example Live Demo Document body {    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample {    font-size: 20px;    font-weight: 500; } JavaScript ArrayBuffer.byteLength property CLICK HERE Click on the above button to see the array buffer size let fillEle = document.querySelector(".sample"); var buffer = new ArrayBuffer(8); var view1 = new DataView(buffer); view1.setInt16(0, 0x2721); fillEle.innerHTML = view1.getInt16(0).toString(16); document.querySelector('.Btn').addEventListener('click',()=>{    fillEle.innerHTML = 'The array buffer size is '+view1.byteLength+' bytes'; }) OutputOn clicking the “CLICK HERE” button −

JavaScript Array Values

AmitDiwan
Updated on 06-May-2020 12:24:26

180 Views

The JavaScript array.values() return an iterator object that contains all the values of a given array.Following is the code for array.values() function −Example Live Demo Document body {    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample {    font-size: 20px;    font-weight: 500; } JavaScript array.values() CLICK HERE Click on the above button to see the array values only let fillEle = document.querySelector(".sample"); let arr = ["cow", "bull", "lion", "tiger", "sheep"]; var entries = arr.entries(); for (let x of entries) fillEle.innerHTML += x + ""; document.querySelector(".Btn").addEventListener("click", () => { ... Read More

JavaScript Array toLocaleString Function

AmitDiwan
Updated on 06-May-2020 12:22:06

164 Views

The JavaScript array.toLocaleString() function returns the elements of an array as a string and are separated by a locale specific string such as comma. It can take locale as parameter which specifies the language tag in which the string is to be converted.Following is the code for the array.toLocaleString() functionExample Live Demo Document body {    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample {    font-size: 20px;    font-weight: 500; } JavaScript array.toLocaleString() CLICK HERE Click on the above button to convert the array to UK locale string let ... Read More

Advertisements