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
Joined: Oct 21, 2000
Posts: 4089
posted
0
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.
SCJP
xavier romea
Ranch Hand
Joined: Jun 28, 2001
Posts: 37
posted
0
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
Joined: Jan 18, 2001
Posts: 39
posted
0
Dear Randall and Xavier; Thank you both for the responses. I will try what you said . Have a good day.
swaroop shastri
Ranch Hand
Joined: Aug 15, 2001
Posts: 65
posted
0
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
Joined: Nov 22, 2008
Posts: 18944
posted
0
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.