Could this code be improved? Would you suggest more sophisticated way of doing client-side signup validation? <!DOCTYPE html><html><head>    <script>        function validateForm() {            var name = document.forms[registrationForm][username].value;            if (name == null || name == ) {                alert(Name must be filled out);                return false;            }            var password = document.forms[registrationForm][password].value;            var repeatPassword = document.forms[registrationForm][passwordAgain].value;            if (password.length < 8) {                alert(Password should contain 8 symbols or more);                return false;            }            if (password != repeatPassword) {                alert(Filled out passwords should match);                return false;            }        }    </script></head><body><h3>SignUp Form</h3><form name=registrationForm onsubmit=return validateForm() action=registration method=post>    Email:<input type=text name=username/><br/><br/>    Password:<input type=password name=password/><br/><br/>    Repeat Password:<input type=password name=passwordAgain/><br/><br/>    <input type=submit value=signup/></form></body></html>
JavaScript validation form
javascript;html;validation
I would suggest a more sophisticated way of doing client-side validation. This all depends on what your design is (if the customer wants it this way, then that's it), but personally, I'd prefer it if you check the field after I've edited it, and if it is not correct, that you change the styling on the field, maybe set an error label. Right now you're throwing alert dialogs around which disrupt flow. By making the validation reactive like that, the user has instant feedback, rather than do -> submit -> error -> repeat which is a cycle that causes frustrations. Imagine you had a separate check for a single digit, or a check to see if there'a  capital in the password, and a check that you're using at least 1 special symbol... the user would trigger these warnings one at a time; they'd end up with about 5 errors (1 for the length, 1 for digit, 1 for capital, 1 for special characters, and then 1 for the repeat password because they forgot).Looking at the code, it seems mostly fine for your purposes; the only thing I'd do is move 8 to a separate constant MIN_PASSWORD_LENGTH.