Answers for "how can i add js validations"

2

javascript login validation

<script language = "JavaScript">
        function validate() {
            var username = document.getElementById("username").value;
            var password = document.getElementById("password").value;
            if (username == null || username == "") {
                alert("Please enter the username.");
                return false;
            }
            if (password == null || password == "") {
                alert("Please enter the password.");
                return false;
            }
            alert('Login successful');
            
        } 
</script>
Posted by: Guest on March-19-2020
2

name validation html

<input type="text" pattern="[a-zA-Z'-'\s]*">
Posted by: Guest on September-18-2020

Browse Popular Code Answers by Language