Form Validation

Results 1 to 3 of 3

Thread: Form Validation

  1. #1
    Join Date
    Dec 1969

    Default Form Validation

    Hi there. I have a login page that needs a bunch of validation. The first thing I need to do is make sure that the name the user entered is in the database. If not, they get an alert message. I&#039ve tried this using pure JavaScript, and also by mixing ASP and JavaScript. All with different sorts of problems.<BR><BR>For example, when I use this format:<BR><BR>...database connection, open recordset<BR>...the Form code<BR>&#060;% dim strUserName<BR>strUserName=Request.Form("name")<BR ><BR>do while not objRS.EOF<BR>if strUserName&#060;&#062;"" and objRS("user") &#060;&#062; strUserName then %&#062;<BR>&#060;script language="JavaScript"&#062;<BR>alert("The name you entered was not found. Please try again");<BR>;<BR>&#060;/script&#062;<BR>&#060;% end if<BR>objRS.MoveNext<BR>Loop %&#062;<BR><BR>The validation part works fine. However, if the user has mistyped and gotten the alert message then entered the correct name (corresponds with database), when the user clicks on the back button, they get stuck in a loop of alerts then redirects.<BR><BR>Then to avoid getting stuck in a loop with the back button, I tried it with JavaScript, except I couldn&#039t figure out how to validate the form field against the database using JavaScript - I know I need to use some sort of JavaScript loop, but I don&#039t know how.<BR><BR>Any solutions for any of these problems would be greatly appreciated!!!!<BR><BR>Thanks<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Form Validation

    Have you tried posting the information to a page & redirecting if not valid:<BR>pg1.asp<BR>&#060;form method="post" action="pg2.asp"&#062;<BR>&#060;input type="text" name="username"&#062;<BR>&#060;input type="submit"&#062;<BR>&#060;/form&#062;<BR>pg2.asp:<BR>&#039do validation<BR>if eof then<BR>response.redirect("pg1.asp")<BR>end if<BR>You can then alert the user of invalid login<BR>on pg1. Pass along notation to code on pg1 via <BR>session,cookie or querystring as suits you.<BR>leo

  3. #3
    yahoo Guest

    Default RE: Form Validation

    Hi.,<BR> the validation is fine and u have to make it&#039s true or false<BR><BR>strusername= request.form("name")<BR><BR>if strusrename &#060;&#062; "" then<BR><BR> alert "maeesage"<BR> return false<BR>else<BR> return true<BR><BR>end if<BR><BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts