im new to html and javascript. I seem to be having problems on my button click. If the username / password are empty it is ment to set the border for there inputbox to red, then let me fill them in again. Problem is that when the input boxes are empty and when i click the button the input boxes get set red for half a second then the webpage ends up at index.html? not sure why i was watching the console in google chrome and it shows
login_button Clicked
index.js:34 username == null
index.js:41 password == null
Navigated to file:////index.html?
Button Click
$('#login_button').click(function () {
console.log("login_button Clicked");
var username = $('#login_username').val();
var password = $('#login_password').val();
if (username == "") {
console.log("username == null");
$('#login_username').css({
"border": '#FF0000 1px solid'
});
}
if (password == "") {
console.log("password == null");
$('#login_password').css({
"border": '#FF0000 1px solid'
});
}
if (username && password) {
console.log("Login");
}
});
i get this in chrome Exception : DOMException: Failed to execute 'querySelectorAll' on 'Element': '*,:x' is not a valid selector.