Hello:
I am a newbie to JavaScript and just started to read a
Javascript book that is about 5 years old. I have also been on the w3schools website. Below is coding that once you load it into Internet Explorer 7, it simply asks you for the user ID and password and is designed to just give you an error message when you do not put the correct used ID and password in. This portion works properly. When you put in the correct user ID and password, you should get an alert statement that states "Logon valid," but instead states "Logon invalid." I have Windows Vista. I tried to adjust the code by adding 2 semicolons but that did not help. The code is below.
Thank you!
I am a newbie to JavaScript and just started to read a
Javascript book that is about 5 years old. I have also been on the w3schools website. Below is coding that once you load it into Internet Explorer 7, it simply asks you for the user ID and password and is designed to just give you an error message when you do not put the correct used ID and password in. This portion works properly. When you put in the correct user ID and password, you should get an alert statement that states "Logon valid," but instead states "Logon invalid." I have Windows Vista. I tried to adjust the code by adding 2 semicolons but that did not help. The code is below.
Thank you!
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] lang="en" xml:lang="en">
<head>
<title>Validate userID and Password</title>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="en-us" />
<meta name="description" content="JavaScript" />
<meta name="keywords" content="JavaScript" />
<!-- the absolute pathname of this file is: -->
<!-- C:\MISCSUP2_10_17_8\MISCSUP2\Javascript_Demystified_Download_Working\ -->
<!-- Ch_2_Page32_thru_34.html -->
<!-- this file was created on Monday, 08/09/10: -->
<!-- this file was updated on Monday, 08/09/10: -->
</head>
<body>
<script language="Javascript" type="text/javascript">
<!--
var userID
var password
userID = prompt('Enter user ID',' ')
password = prompt('Enter password',' ')
if (userID == 'ScubaBob' && password == 'diving')
{
alert('Logon valid')
}
else
{
alert('Logon invalid')
}
-->
</script>
</body>
</html>