• Form Validation/Submit Button

    Author
    Topic
    #370841

    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:

    Viewing 1 reply thread
    Author
    Replies
    • #587794

      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 thumbup

    • #587848

      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.

      • #587858

        I have the following code before the tag:

        The sub procedure code performing the validation occurs after the tag.
        <%
        Sub ChangePwdButton_OnClick()
        If fChangePwd.CurrentPasswordSession(“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
        %>

        • #587861

          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

          • #587864

            [indent]


            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.


            [/indent]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! joy

          • #588554

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

    Viewing 1 reply thread
    Reply To: Form Validation/Submit Button

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: