Fix check for an empty input or ESC key press
According to the task both of these should give an alert('Canceled'). Previous solution implied that both empty input and ESC key return null, but in Chrome 64.0.3282.186 an empty input returns '' instead of null. So we are adding an additional check.
This commit is contained in:
parent
9365275467
commit
6410140c37
1 changed files with 2 additions and 2 deletions
|
@ -9,13 +9,13 @@ if (userName == 'Admin') {
|
||||||
|
|
||||||
if (pass == 'TheMaster') {
|
if (pass == 'TheMaster') {
|
||||||
alert( 'Welcome!' );
|
alert( 'Welcome!' );
|
||||||
} else if (pass == null) {
|
} else if (pass == '' || pass == null) {
|
||||||
alert( 'Canceled.' );
|
alert( 'Canceled.' );
|
||||||
} else {
|
} else {
|
||||||
alert( 'Wrong password' );
|
alert( 'Wrong password' );
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (userName == null) {
|
} else if (userName == '' || userName == null) {
|
||||||
alert( 'Canceled' );
|
alert( 'Canceled' );
|
||||||
} else {
|
} else {
|
||||||
alert( "I don't know you" );
|
alert( "I don't know you" );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue