Untitled

mail@pastecode.io avatar
unknown
javascript
2 years ago
941 B
1
Indexable
Never
<script type="text/javascript">
            function checkForm() 
            {
                var errors = "";
                if(document.getElementById("surname").value == "") {
                    errors += "Surname missing ";
                }

                if(document.getElementById("username").value === "pippo" || "pluto" || "topolino") {
                    errors += " Username cannot be equal to pippo pluto or topolino";
                }

                if(document.getElementById("year").value < 2004) {
                    errors += " Year cannot be minor than 2004";
                }

                if(document.getElementById("password").value != document.getElementById("repeatpassword").value) {
                    errors += " Password is different to RepeatPassword";
                }

                if(errors.length != 0) {
                    alert(errors);
                }
            }
        </script>