Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Aug 2001
    Location
    USA
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form Validation/Submit Button

    I have an asp page creating a form for a user to change their login password (changepassword.asp).
    After entering the current password and the new password twice, I want the submit button to validate the password for our requirements before submitting the data to the processing page (updatepassword.asp).

    When I click the button on changepassword.asp, nothing happens.
    Am I incorrectly setting up the validation?

    ASP CODE in attached file:
    Attached Files Attached Files

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Validation/Submit Button

    This may not be an option for you, but have you considered using client-side Javascript to validate? I usually validate client-side stuff with Javascript due to higher compatibility.

    Post back if you need a hand with the javascript validation code...

    HTH <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Form Validation/Submit Button

    Are you trying to embed the OnClick procedure into the page send to the client? If so, take off the ASP script tags and use regular client-side script tags. Otherwise, you have to use the arduous Response.Write method.

  4. #4
    2 Star Lounger
    Join Date
    Aug 2001
    Location
    USA
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Validation/Submit Button

    I have the following code before the </Form> tag:
    <input type="button" value="Change" name="ChangePwdButton" tabindex="4">

    The sub procedure code performing the validation occurs after the </Form> tag.
    <%
    Sub ChangePwdButton_OnClick()
    If fChangePwd.CurrentPassword<>Session("vPwd") then
    'Alert "Either you are not logged in, or your login has expired. You must log in again."
    Response.Redirect "/memberlogin.htm"
    Exit Sub
    End If

    If len(fChangePwd.NewPassword.Value)<>7 then
    'Alert "Your password must be 7 characters/digits long."
    fChangePwd.NewPassword.focus
    Exit Sub
    end if

    If InStr(1,fChangePwd.NewPassword.Value,"0123456789") = 0 then
    'Alert "Your password must contain at least one (1) digit."
    fChangePwd.NewPassword.focus
    Exit Sub
    end if

    If fChangePwd.NewPassword.Value <> fChangePwd.NewPasswordVerification.Value then
    'Alert "Your did not re-enter the same password. Try again!"
    fChangePwd.NewPassword.focus
    Exit Sub
    end if

    Call fChangePwd.submit()
    End Sub
    %>

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Form Validation/Submit Button

    If you read < % to mean the same thing as <SCRIPT RunAt=Server I think you will see what I am saying. Server-side code does not end up in the page served to the user's browser.

    I could be wrong

  6. #6
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Validation/Submit Button

    <hr>Now...only IE runs VBScript, so if you don't have control over the browser used to view your page, you might have to recode it in JavaScript. <hr>
    Of course, you could start using the .NET framework where the Browser is sniffed by internal code and the appropriate code is automatically sent by the server... (Not to mention the mixed client/server validation setup.)

    ASP.NET is a new and exciting world! <img src=/S/joy.gif border=0 alt=joy width=23 height=23>

  7. #7
    2 Star Lounger
    Join Date
    Aug 2001
    Location
    USA
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form Validation/Submit Button

    Yes, that helped.
    I'm recoding the function into JavaScript.

Posting Permissions

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