on 02-26-2007 8:25 AM
Hi all,
I need a javascript to validate the user when tries to access an web page.
when the user gives the url , it should ask for the password and if it is valid, the page should be loaded else it should display a message like "u r not authorized to view this page ".
Regards,
Eben
Hi,
<html>
<head>
<script language="javascript">
function check()
{
alert("enter user name and password");
}
function reload()
{
form.action="your page"
form.submit();
}
</script>
</head>
<body>
here you can write code for what you want and write select statement for picking data from database for valid person. if database fails to retrive data of a entered person, then you can write the following code here:
<script language="javascript">
alert("you are not authorized person, register you profile");
</script>
write the code on button like this
<input type="button" name="submit" onClick="check();reload()">
Do like this, you will get the result.
Regards,
Bhaskar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Alerting the user to enter a password is possible using javscript
<html>
<head>
<script language="JavaScript:>
function alertForPwd() {
alert("Please enter valid password for entering the website");
}
</script>
</head>
<body onload="Javascript: alertForPwd();">
....
</body>
</html>
For checking whether the user entered password is correct is not possible with javascript alone. you either need have server side scripting.
Regards,
Sridevi
Note: Award points if found useful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Eben,
why must it be JavaScript? You can have Basic Auth, Cert Auth, etc.
Regards
Gregor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.