I am a beginner to JavaScript and I know about jQuery Validations however I do not want to use a foundation like jQuery just yet.
I am wondering if what I have done its good or if there is another way to do it other then jQuery?
I won't post the html just the JS. It does work by the way! Just wondering if there is a better way!
function validateForm() {
var userName = document.forms["register"]["username"].value;
var passWord = document.forms["register"]["password"].value;
var c_passWord = document.forms["register"]["c_password"].value;
if (userName == null || userName == "") {
alert("Your username can not be empty!");
return false;
} else if (userName.length < 3) {
alert("Your username must be atleast 3 characters long!");
return false;
}
if (passWord == null || passWord == "") {
alert("Your password can not be empty");
return false;
} else if (passWord.length < 5) {
alert("Your password must be more the 5 characters");
return false;
}
}