Multiple errors displayed in console
up vote
-1
down vote
favorite
I am writing a very simple code for a login page in a website hacker rank. But the test is failing continuously. It's driving me nuts. Can someone help me!! The same code if I run separately in chrome, it is running fine.
Here is my HTML
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="index.js"></script>
</head>
<body>
<div class="login-page">
<div class="form">
<input type="text" id="username" placeholder="username"/>
<input type="password" id="password" placeholder="password"/>
<button id="login" type="button" onclick="login()">Login</button>
</br>
</div>
</div>
</body>
</html>
This is index.js errors are included in comments
function login () {
var name = $("#username").val();
var pwd = $("#password").val();
if ( (name === 'admin') && (pwd === 'password') ){ //there should be no space in this paren
alert('You are a valid user'); //alert is not defined. Trailing spaces not allowed
} else {
alert('You are not a valid user');
}
};
jquery login
|
show 7 more comments
up vote
-1
down vote
favorite
I am writing a very simple code for a login page in a website hacker rank. But the test is failing continuously. It's driving me nuts. Can someone help me!! The same code if I run separately in chrome, it is running fine.
Here is my HTML
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="index.js"></script>
</head>
<body>
<div class="login-page">
<div class="form">
<input type="text" id="username" placeholder="username"/>
<input type="password" id="password" placeholder="password"/>
<button id="login" type="button" onclick="login()">Login</button>
</br>
</div>
</div>
</body>
</html>
This is index.js errors are included in comments
function login () {
var name = $("#username").val();
var pwd = $("#password").val();
if ( (name === 'admin') && (pwd === 'password') ){ //there should be no space in this paren
alert('You are a valid user'); //alert is not defined. Trailing spaces not allowed
} else {
alert('You are not a valid user');
}
};
jquery login
If the code works fine but the tests don't pass, maybe the tests are wrong.....
– peeebeee
Nov 8 at 11:16
Well it's working tho... what's the problem?!
– Islam Elshobokshy
Nov 8 at 11:22
What are the errors in the console?
– Djave
Nov 8 at 11:24
Djave I have included them in the comments for index.js
– Anusha
Nov 8 at 11:25
1
So for the 'space in parens' error, did you tryif ((name === 'admin') && (pwd === 'password'))- this removes spaces near the parens but retains spaces round the infix operators.
– peeebeee
Nov 8 at 12:25
|
show 7 more comments
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I am writing a very simple code for a login page in a website hacker rank. But the test is failing continuously. It's driving me nuts. Can someone help me!! The same code if I run separately in chrome, it is running fine.
Here is my HTML
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="index.js"></script>
</head>
<body>
<div class="login-page">
<div class="form">
<input type="text" id="username" placeholder="username"/>
<input type="password" id="password" placeholder="password"/>
<button id="login" type="button" onclick="login()">Login</button>
</br>
</div>
</div>
</body>
</html>
This is index.js errors are included in comments
function login () {
var name = $("#username").val();
var pwd = $("#password").val();
if ( (name === 'admin') && (pwd === 'password') ){ //there should be no space in this paren
alert('You are a valid user'); //alert is not defined. Trailing spaces not allowed
} else {
alert('You are not a valid user');
}
};
jquery login
I am writing a very simple code for a login page in a website hacker rank. But the test is failing continuously. It's driving me nuts. Can someone help me!! The same code if I run separately in chrome, it is running fine.
Here is my HTML
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="index.js"></script>
</head>
<body>
<div class="login-page">
<div class="form">
<input type="text" id="username" placeholder="username"/>
<input type="password" id="password" placeholder="password"/>
<button id="login" type="button" onclick="login()">Login</button>
</br>
</div>
</div>
</body>
</html>
This is index.js errors are included in comments
function login () {
var name = $("#username").val();
var pwd = $("#password").val();
if ( (name === 'admin') && (pwd === 'password') ){ //there should be no space in this paren
alert('You are a valid user'); //alert is not defined. Trailing spaces not allowed
} else {
alert('You are not a valid user');
}
};
jquery login
jquery login
asked Nov 8 at 11:10
Anusha
4029
4029
If the code works fine but the tests don't pass, maybe the tests are wrong.....
– peeebeee
Nov 8 at 11:16
Well it's working tho... what's the problem?!
– Islam Elshobokshy
Nov 8 at 11:22
What are the errors in the console?
– Djave
Nov 8 at 11:24
Djave I have included them in the comments for index.js
– Anusha
Nov 8 at 11:25
1
So for the 'space in parens' error, did you tryif ((name === 'admin') && (pwd === 'password'))- this removes spaces near the parens but retains spaces round the infix operators.
– peeebeee
Nov 8 at 12:25
|
show 7 more comments
If the code works fine but the tests don't pass, maybe the tests are wrong.....
– peeebeee
Nov 8 at 11:16
Well it's working tho... what's the problem?!
– Islam Elshobokshy
Nov 8 at 11:22
What are the errors in the console?
– Djave
Nov 8 at 11:24
Djave I have included them in the comments for index.js
– Anusha
Nov 8 at 11:25
1
So for the 'space in parens' error, did you tryif ((name === 'admin') && (pwd === 'password'))- this removes spaces near the parens but retains spaces round the infix operators.
– peeebeee
Nov 8 at 12:25
If the code works fine but the tests don't pass, maybe the tests are wrong.....
– peeebeee
Nov 8 at 11:16
If the code works fine but the tests don't pass, maybe the tests are wrong.....
– peeebeee
Nov 8 at 11:16
Well it's working tho... what's the problem?!
– Islam Elshobokshy
Nov 8 at 11:22
Well it's working tho... what's the problem?!
– Islam Elshobokshy
Nov 8 at 11:22
What are the errors in the console?
– Djave
Nov 8 at 11:24
What are the errors in the console?
– Djave
Nov 8 at 11:24
Djave I have included them in the comments for index.js
– Anusha
Nov 8 at 11:25
Djave I have included them in the comments for index.js
– Anusha
Nov 8 at 11:25
1
1
So for the 'space in parens' error, did you try
if ((name === 'admin') && (pwd === 'password')) - this removes spaces near the parens but retains spaces round the infix operators.– peeebeee
Nov 8 at 12:25
So for the 'space in parens' error, did you try
if ((name === 'admin') && (pwd === 'password')) - this removes spaces near the parens but retains spaces round the infix operators.– peeebeee
Nov 8 at 12:25
|
show 7 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206555%2fmultiple-errors-displayed-in-console%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If the code works fine but the tests don't pass, maybe the tests are wrong.....
– peeebeee
Nov 8 at 11:16
Well it's working tho... what's the problem?!
– Islam Elshobokshy
Nov 8 at 11:22
What are the errors in the console?
– Djave
Nov 8 at 11:24
Djave I have included them in the comments for index.js
– Anusha
Nov 8 at 11:25
1
So for the 'space in parens' error, did you try
if ((name === 'admin') && (pwd === 'password'))- this removes spaces near the parens but retains spaces round the infix operators.– peeebeee
Nov 8 at 12:25