Posted By: salmasarai | Aug 28th @ 3:04 AM
page 1 of 1
Comments: 3 | Views: 411

i have designed a page With Username and Password as its labels with a Submit button,i have written the following code in javascript
<html>

<head>

<title>Title of page</title>

<script type="text/javascript">

function disp_alert()

{
var x = document.getElementById('<%txtUsername.ClientID%>').value;

var y = document.getElementById('<%txtPassword.ClientID%>').value;

if(x = 'naga' && y = 'naga')

alert('welcome');

else

alert('enter valid id and password');

}

</script>

</head>

<body>

</body>

</html>

but i am not getting the pop window .Plz help me.

Sven Groot
Sven Groot
You can't have everything; after all, where would you put it?
it should be x=='naga' (note the double equals sign).

But doing password validation in client script is horribly insecure. Everybody will be able to break into the site.
Salmasarai you really dont want to do this as if you just click view source on the page they will see what password you are expecting. It needs to be submitted back to the server and validated.

Have a look at something like forms authentication tutorial at:
http://www.4guysfromrolla.com/webtech/110701-1.shtml
W3bbo
W3bbo
The Master of Baiters
Also whilst you haven't told ASP.NET to actually render the ClientIDs, you've just made a statement and not an expression.

Should be:

var x = document.getElementById("<%= txtUsername.ClientID %>").value;
page 1 of 1
Comments: 3 | Views: 411