Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 14th, 2004, 10:30 AM
Registered User
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Non-functioning validation2

Hi all - again. Validation is my nemises!!
The problem with this code is that error messages are showing but form is submitted anyway. Also if NewPassword is different from ConfirmNewPassword , the string/value of NewPassword is submitted
and entered into the database irrespective of error. Once again , thankyou for taking time to read this and offer any solutions,
cheers,
larry101
CHANGE PASSWORD PAGE CODE

<HTML>
<HEAD>
<SCRIPT LANGUAGE="VBScript">

    Function TextBoxValid(textbox)
      Dim textlen
      TextBoxValid = True
      textlen = Len(textbox)

      If textlen <> 8 Then
         TextBoxValid = False
      End If
    End Function

    Function checkInput

      If TextBoxValid(ChangePass.NewPassword.value)= False Then
         checkInput = False
         MsgBox "The required number of characters for a password is 8",0,"ERROR"
         Exit Function
      End If

      If TextBoxValid(ChangePass.ConfirmNewPassword.value)= False Then
         checkInput = False
         MsgBox "The required number of characters for password confirmation is 8",0,"ERROR"
         Exit Function
      End If

      If ((ChangePass.NewPassword.value) <> (ChangePass.ConfirmNewPassword.value)) Then
         checkInput = False
         MsgBox "The new password you entered does not match the confirm password.
         Please re-enter",0,"ERROR"
         Exit Function
      End If

    End Function

    Function formValid()
      If checkInput = True Then
        formValid = True
      Else
        formValid = False
      End If
    End Function

</SCRIPT>

<TITLE>Update User Password</TITLE>
</HEAD>






<BODY>
<FORM NAME="ChangePass" ACTION="UpdatePassTable.asp" METHOD="POST" onSubmit="formValid()">
Old Password :&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbs p&nbsp&nbsp&nbsp&nbsp&nbsp
<INPUT TYPE="Password" NAME="OldPassword" SIZE="8" MAXLENGTH="8">
<BR>
<BR>
New Password :&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbs p&nbsp&nbsp&nbsp
<INPUT TYPE="Password" NAME="NewPassword" SIZE="8" MAXLENGTH="8">
<BR>
Confirm New Password :
<INPUT TYPE="Password" NAME="ConfirmNewPassword" SIZE="8" MAXLENGTH="8">
<BR>
<BR>
<INPUT TYPE="Submit" VALUE="Submit">
&nbsp
&nbsp
<INPUT TYPE="Reset" VALUE="Reset">

<BR>
</TABLE>
</FORM>
</BODY>
</HTML>



UpdatePassTable.asp CODE – checks usertype and updates the associated table

<% @LANGUAGE=VBScript %>




<%

   Dim objConn, query, objRS

   Set objConn = Server.CreateObject("ADODB.Connection")
   objConn.Open "DSN=Profiles&Placements"

   If (Session("usertype") =0) Then

      Set objRS = Server.CreateObject("ADODB.Recordset")
      objRS.Open "TPCLogin", objConn, adOpenDynamic, adLockOptimistic

        While Not objRS.EOF
          If (objRS("username") = Session("username")) Then
             objRS.Delete
          End If
          objRS.MoveNext
        Wend
      objRS.Close

      query = "SELECT * FROM [TPCLogin]"

      Set objRS = Server.CreateObject("ADODB.Recordset")
      objRS.Open query, objConn, adOpenDynamic, adLockOptimistic

      objRS.AddNew
      objRS("username")= Session("username")
      objRS("password")= Request.Form("NewPassword")
      objRS.Update

   Else

      Set objRS = Server.CreateObject("ADODB.Recordset")
      objRS.Open "StudLogin", objConn, adOpenDynamic, adLockOptimistic

        While Not objRS.EOF
          If (objRS("username") = Session("username")) Then
             objRS.Delete
          End If
          objRS.MoveNext
        Wend
      objRS.Close

      query = "SELECT * FROM [StudLogin]"

      Set objRS = Server.CreateObject("ADODB.Recordset")
      objRS.Open query, objConn, adOpenDynamic, adLockOptimistic

      objRS.AddNew
      objRS("username")= Session("username")
      objRS("password")= Request.Form("NewPassword")
      objRS.Update


   End If


   objRS.Close
   Set objRs = Nothing

   objConn.Close
   Set objConn = Nothing

   Response.Redirect "UserTypeCheck.asp"

%>





 
Old September 16th, 2004, 08:08 AM
Friend of Wrox
 
Join Date: Sep 2004
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sureshbabu Send a message via Yahoo to sureshbabu
Default

<%@ Language=VBScript %>
<HTML>
<HEAD>

<SCRIPT LANGUAGE="VBScript">

 Function RadioGroupValid(radGroup)
   Dim radNo
   RadioGroupValid = False

   For radNo=0 to radGroup.Length-1
     If radGroup(radNo).Checked = True Then
        RadioGroupValid = True
     End If
   Next
 End Function

 Function TextBoxValid(textbox)
  Dim textlen
  TextBoxValid = True
  textlen = Len(textbox)
      If textlen <> 8 Then
              TextBoxValid = False
     End If
 End Function

 Function checkInput()
  If RadioGroupValid(login.usertype)= False Then
     checkInput = False
     MsgBox "You have forgotten to select a usertype",0,"ERROR"
     Exit Function
  End If

  If TextBoxValid(login.username.value)= False Then
     checkInput = False
     MsgBox "The required number of characters for a username is 8",0,"ERROR"
     Exit Function
  End If

  If TextBoxValid(login.password.value)= False Then
     checkInput = False
     MsgBox "The required number of characters for a password is 8",0,"ERROR"
     Exit Function
  End If
      checkInput = True
 End Function

 Function formValid()

    If checkInput = True Then
       formValid = True

       document.login.action = "CheckLogin.asp"
       document.login.submit
    Else
      formValid = False
    End If
 End Function

</SCRIPT>
<TITLE> </TITLE>
</HEAD>

<BODY>
<CENTER><H2>LOGIN</H2></CENTER>

<FORM NAME="login" METHOD="POST" >

Please indicate the type of user you are by selecting from either
<BR>
<input type="radio" name="usertype" value="0">Placement Co-ordinator
<BR>
<input type="radio" name="usertype" value="1">Student
<BR>
<BR>
Please enter both your Username and Password.
<BR>
<BR>
Username : <input type="text" name="username" value="" size="8" maxlength="8">
<BR>
Password : <input type="password" name="password" value="" size="8" maxlength="8">
<BR>
<BR>
<input type="Button" value="Login" onclick="formValid()">
<input type="Reset" name="Reset" value="Clear">
<BR>
<BR>
</FORM>
</BODY>
</HTML>







Similar Threads
Thread Thread Starter Forum Replies Last Post
String replace not functioning properly ghari ASP.NET 1.0 and 1.1 Professional 3 January 27th, 2006 12:16 AM
Multi Functioning Combo Boxes / Probs socoolbrewster Access 3 March 3rd, 2005 04:36 AM
Dynamic freport list not functioning dbkester Access 0 December 28th, 2003 01:10 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.