Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help!help!Help!

 
Michael.H.Sun
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friends,
I am trying to validate userID and password with javaScript. I am comparing the userid user entered with the ones in the database. Can anyone there check my logic? Iam using Microsoft Interdev and Personal Web server. Why does it say Reqest undefined? What should I do?
Thanks.
function invalidForm(passForm) {

if (passForm.userid.value == "") {
alert("You must enter a userid")
passForm.userid.focus()
return false
}

if (passForm.password.value == "") {
alert("You must enter a password")
passForm.password.focus()
return false
}

// Get the user-entered username and password
userid=Request.Form("userid")
password=Request.Form("password")
// Set the SQL String
/*var sqlstring = "SELECT userid, password FROM USERS WHERE userid = '" + userid + "'"
rsLogin.setSQLText(sqlstring)
//Open the recordset
rsLogin.open()
if (rsLogin.EOF) {
Alert("invalidusername")
}

if (Trim(rsLogin.fields.getValue("password"))=Trim(password) {
Response.Redirect("home.asp")
}
else {Alert ("invalidpassword")
}

// Close the recordset
rsLogin.close()
}
 
Randall Twede
Ranch Hand
Posts: 4405
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I may be way off base but could it be because you capitalized request maybe userid=request.Form("userid") will work.
also is Form the name you gave to the html form object?
I dont know js very well and dont know server side js at all really(I like java better), but i did read that js is case sensitive.
 
xavier romea
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can see only one error. It's:
if (Trim(rsLogin.fields.getValue("password"))=Trim(password)
you use a single = instead of a double == and the parenthesis ending the condition. A single = is the symbol of affectation and a double = the symbol of equality
 
Michael.H.Sun
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Randall and Xavier;
Thank you both for the responses. I will try what you said . Have a good day.
 
swaroop shastri
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael,
I guess you have combined Javascript with ASP? I mean client side script and server side script.
The browser(client) will not understand the 'request' object.
[This message has been edited by swaroop shastri (edited August 15, 2001).]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Technically, ASP is only an application of JavaScript (or VBScript). JavaScript is the default on the client and VBScript is the default for IIS server-side code. However, either can be used in either situation. The only thing that ASP really brings to the table is an API for server functions that you can access with JavaScript or VBScript.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic