Why code not working?!

function validation() {

	var username = document.getElementById("username").value;
	var password = document.getElementById("password").value;
	var identity = document.getElementById("identity").value;
	var operation = document.getElementById("operation").value;
	var username_message = document.getElementById("username_message").value;
	var password_message = document.getElementById("password_message").value;
	var identity_message = document.getElementById("identity_message").value;
	var operation_message = document.getElementById("operation_message").value;

	if (username == null || username.length == 0) {
		document.getElementById("username_message").innerText = "❌ You forgot to fill in some important field.";
        document.getElementById("username_message").style.color = "#8a0303";
        document.getElementById("username").style.border = "1px solid #8a0303";
	} else if (username.length < 6 || username.length > 32) {
		document.getElementById("username_message").innerText = "❌ You must enter username between 6 and 32 characters.";
	    document.getElementById("username_message").style.color = "#8a0303";
	    document.getElementById("username").style.border = "1px solid #8a0303";
	} else if (username.length >= 6 && username.length < 33) {
		document.getElementById("username_message").innerText = "";
	    document.getElementById("username").style.border = "1px solid #CCC";
	} else if (password == null || password.length == 0) {
		document.getElementById("password_message").innerText = "❌ You forgot to fill in some important field.";
        document.getElementById("password_message").style.color = "#8a0303";
        document.getElementById("password").style.border = "1px solid #8a0303";
	} else if (password.length < 8 || password.length > 42) {
		document.getElementById("password_message").innerText = "❌ You must enter password between 6 and 32 characters.";
        document.getElementById("password_message").style.color = "#8a0303";
        document.getElementById("password").style.border = "1px solid #8a0303";
	} else if (password.length >= 8 || password.length < 43) {
		document.getElementById("password_message").innerText = "";
	    document.getElementById("password").style.border = "1px solid #CCC";
	} else if (identity == null || identity.length == 0) {
		document.getElementById("identity_message").innerText = "❌ You forgot to fill in some important field.";
        document.getElementById("identity_message").style.color = "#8a0303";
        document.getElementById("identity").style.border = "1px solid #8a0303";
	} else if (identity.length < 16 || identity.length > 16) {
		document.getElementById("identity_message").innerText = "❌ You must enter your real identity number.";
        document.getElementById("identity_message").style.color = "#8a0303";
        document.getElementById("identity").style.border = "1px solid #8a0303";
	} else if (identity.length == 16) {
		document.getElementById("identity_message").innerText = "";
	    document.getElementById("identity").style.border = "1px solid #CCC";
	} else if (operation == null || operation.length == 0) {
		document.getElementById("operation_message").innerText = "❌ You forgot to fill in some important field.";
        document.getElementById("operation_message").style.color = "#8a0303";
        document.getElementById("operation").style.border = "1px solid #8a0303";
	}  else {
		document.getElementById("form").action = "https://api.slapform.com/WFRPQFIf0"; 
	}
}

hi friend, how can we help you?

why code not working for login validation?

You are going to have to provide a lot more information for anyone to reasonably be able to help you.

everything working fine except else

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.