Universal Form Validator ASP Support Product Page

This topic was archived

error....

Reported 29 Oct 2009 12:04:52
1
has this problem
29 Oct 2009 12:04:52 stephan ludovic posted:
Hi,
I m testing the extension with an insert form and sql server database.
The form works without validator extension but can't work with the extension...!

Here the asp code of my page

If i can have some help

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../../Connections/sqlfncas.asp" -->
<!--#include file="../../ScriptLibrary/dmxValidator.asp" -->
<
%'Our Function generatePassword accepts one parameter 'passwordLength'
'passwordLength will obviously determine the password length.
'The aplhanumeric character set is assigned to the variable sDefaultChars
Function generatePassword(passwordLength)
'Declare variables
Dim sDefaultChars
Dim iCounter
Dim sMyPassword
Dim iPickedChar
Dim iDefaultCharactersLength
Dim iPasswordLength

Dim pass

'Initialize variables
sDefaultChars="abcdefghijklmnopqrstuvxyz0123456789"
iPasswordLength=passwordLength
iDefaultCharactersLength = Len(sDefaultChars) 
Randomize'initialize the random number generator
'Loop for the number of characters password is to have
For iCounter = 1 To iPasswordLength
'Next pick a number from 1 to length of character set 
iPickedChar = Int((iDefaultCharactersLength * Rnd) + 1) 
'Next pick a character from the character set using the random number iPickedChar
'and Mid function
sMyPassword = sMyPassword & Mid(sDefaultChars,iPickedChar,1)
Next 
generatePassword = sMyPassword
End Function
'Response.write generatePassword(6) 'Call the function & pass in 6 as the parameter 

pass = generatePassword(6)
 'Response.Write pass 
%>

<
%'Our Function generatePassword accepts one parameter 'passwordLength'
'passwordLength will obviously determine the password length.
'The aplhanumeric character set is assigned to the variable sDefaultChars
Function generatePassword(passwordLength)
'Declare variables
Dim sDefaultChars
Dim iCounter
Dim sMyPassword
Dim iPickedChar
Dim iDefaultCharactersLength
Dim iPasswordLength

Dim pass2

'Initialize variables
sDefaultChars="abcdefghijklmnopqrstuvxyz0123456789"
iPasswordLength=passwordLength
iDefaultCharactersLength = Len(sDefaultChars) 
Randomize'initialize the random number generator
'Loop for the number of characters password is to have
For iCounter = 1 To iPasswordLength
'Next pick a number from 1 to length of character set 
iPickedChar = Int((iDefaultCharactersLength * Rnd) + 1) 
'Next pick a character from the character set using the random number iPickedChar
'and Mid function
sMyPassword = sMyPassword & Mid(sDefaultChars,iPickedChar,1)
Next 
generatePassword = sMyPassword
End Function
'Response.write generatePassword(6) 'Call the function & pass in 6 as the parameter 

pass2 = generatePassword(6)
 Response.Write pass2 
%>
<
%Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<
%' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
  If condition = "" Then
    MM_IIf = ifFalse
  Else
    MM_IIf = ifTrue
  End If
End Function
%>
<
%' Universal Form Validator ASP 1.5.0
dim dmxval1, DMX_validateAction
set dmxval1 = new dmxValidator
dmxval1.ScriptFolder = "../../ScriptLibrary"
dmxval1.CSValidateOnChange = true
dmxval1.CSValidateOnSubmit = true
dmxval1.ReportType = 4
dmxval1.ErrorFont =  "Arial"
dmxval1.ErrorFontSize = 12
dmxval1.ErrorColor = "#ffffff"
dmxval1.ErrorBold = true
dmxval1.ErrorItalic = false
dmxval1.ErrorImage = ""
dmxval1.ErrorFixed = "Custom"
dmxval1.ErrorPadding = 4
dmxval1.BorderColor = "#FF0000"
dmxval1.CssErrorFile = "validatorError1"
dmxval1.ErrorPreset = "error_five.txt"
dmxval1.TooltipPosition = "top"
dmxval1.CssHintFile = "validatorHint1"
dmxval1.HintPreset = "blue.txt"
dmxval1.HintTooltipPosition = "top"
dmxval1.HintBorderColor = "#0099ff"
dmxval1.HintBorderStyle = "solid"
dmxval1.HintBgColor = "#003399"
dmxval1.HintTextColor = "#ffffff"
dmxval1.HintTextFont = "Arial"
dmxval1.HintTextSize = 12
dmxval1.HintTextBold = false
dmxval1.HintTextItalic = false
dmxval1.HintBoxWidth = 200
dmxval1.HintImage = ""
dmxval1.HintFixed = "Custom"
dmxval1.HintPadding = 4
dmxval1.UseCustomFocusClass = "fixed"
dmxval1.FocusBorderStyle = "groove"
dmxval1.FocusBorderSize = 1
dmxval1.FocusBorderColor = "#C3D9FF"
dmxval1.FocusBgColor = "#FFFFFF"
dmxval1.FocusTextColor = "#000000"
dmxval1.UseCustomValidClass = "fixed"
dmxval1.ValidBorderStyle = "groove"
dmxval1.ValidBorderSize = 1
dmxval1.ValidBorderColor = "#00FF00"
dmxval1.ValidBgColor = "#FFFFFF"
dmxval1.ValidTextColor = "#000000"
dmxval1.UseCustomInvalidClass = "fixed"
dmxval1.InvalidBorderStyle = "groove"
dmxval1.InvalidBorderSize = 2
dmxval1.InvalidBorderColor = "#FF0000"
dmxval1.InvalidBgColor = "#FFFFFF"
dmxval1.InvalidTextColor = "#000000"
dmxval1.AddRule "formulaire1", "email", "allformats", ",,", "true", "", "", "", ""
dmxval1.Validate
%>
<
%If (CStr(Request("MM_insert")) = "formulaire1") Then
  If (Not MM_abortEdit) Then
    ' execute the insert
    Dim MM_editCmd

    Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_sqlfncas_STRING
    MM_editCmd.CommandText = "INSERT INTO dbo.Etablissements (acetablist, nometablist, loginetab, pwdetablissement, rce, nomresponsableenquete, emailrespetablisst, telrespenquete) VALUES (?, ?, ?, ?, ?, ?, ?, ?)" 
    MM_editCmd.Prepared = true
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 5, 1, -1, MM_IIF(Request.Form("acetablist"), Request.Form("acetablist"), null)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 50, Request.Form("nometablist")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 10, Request.Form("login")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 50, Request.Form("pwd")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 5, 1, -1, MM_IIF(Request.Form("rce"), 1, 0)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 203, 1, 1073741823, Request.Form("respenquete")) ' adLongVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 202, 1, 50, Request.Form("email")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 202, 1, 50, Request.Form("tel")) ' adVarWChar
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    ' append the query string to the redirect URL
    Dim MM_editRedirectUrl
    MM_editRedirectUrl = "ajoutetab.asp"
    If (Request.QueryString <> "") Then
      If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
        MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
      Else
        MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
      End If
    End If
    Response.Redirect(MM_editRedirectUrl)
  End If
End If
%>
<
%Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_sqlfncas_STRING
Recordset1_cmd.CommandText = "SELECT * FROM dbo.Etablissements" 
Recordset1_cmd.Prepared = true

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
<
%Dim academie
Dim academie_numRows

Set academie = Server.CreateObject("ADODB.Recordset")
academie.ActiveConnection = MM_sqlfncas_STRING
academie.Source = "SELECT * FROM dbo.academie"
academie.CursorType = 0
academie.CursorLocation = 2
academie.LockType = 1
academie.Open()

academie_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
<link rel="stylesheet" href="../../Styles/dmxValidator/validatorHint1.css" type="text/css" />
<link rel="stylesheet" href="../../Styles/dmxValidator/validatorError1.css" type="text/css" />
<script src="../../ScriptLibrary/jsvat.js" type="text/javascript"></script>
<script src="../../ScriptLibrary/jquery-latest.pack.js" type="text/javascript"></script>
<script src="../../ScriptLibrary/jquery.inputHintBox.js" type="text/javascript"></script>
<script src="../../ScriptLibrary/jquery.maskedinput-1.2.2.js" type="text/javascript"></script>
<script src="../../ScriptLibrary/jquery.validate.min.js" type="text/javascript"></script>
<script src="../../ScriptLibrary/dmx.jquery.validate.js" type="text/javascript"></script>
<script src="../../ScriptLibrary/jquery.tooltip.min.js" type="text/javascript"></script>
<script src="../../ScriptLibrary/jquery.hoverIntent.min.js" type="text/javascript"></script>
<% 
' dmxValidatorJSStart
dmxval1.GenerateJavascriptAndCss
' dmxValidatorJSEnd
%>
</head>

<body>
<br />
<br />
<br />
<br />
<form action="<%=MM_editAction%>" method="POST" name="formulaire1" id="formulaire1">
  <table align="center">
    <tr valign="baseline">
      <td nowrap align="right">Acetablist:</td>
      <td><label>
        <select name="acetablist" id="acetablist">
          <
%While (NOT academie.EOF)
%>
          <option <%= dmxSetSelectOption("<%=(academie.Fields.Item("idacademie").Value)%>",FormRequest("acetablist"),false) %> value="<%=(academie.Fields.Item("idacademie").Value)%>"
          <%If (Not isNull((academie.Fields.Item("idacademie").Value))) Then If (CStr(academie.Fields.Item("idacademie").Value) = CStr((academie.Fields.Item("idacademie").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>
><%=(academie.Fields.Item("academie").Value)%></option>
<
%  academie.MoveNext()
Wend
If (academie.CursorType > 0) Then
  academie.MoveFirst
Else
  academie.Requery
End If
%>
        </select>
      </label>      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Nometablist:</td>
      <td><input type="text" name="nometablist" id="nometablist" value="<%= dmxSetValue("", FormRequest("nometablist")) %>" size="32">      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">login etablissement :</td>
      <td><input type="text" name="login" id="login" value="<%= dmxSetValue( pass , FormRequest("login")) %>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Pwd etablissement:</td>
      <td><input type="text" name="pwd" id="pwd" value="<%= dmxSetValue( pass2 , FormRequest("pwd")) %>" size="32">      </td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap> Etablissement RCE     </td>
      <td><input name="rce" type="checkbox" id="rce" value="checkbox" <%= dmxSetCheckbox("checkbox",FormRequest("rce")) %> /></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap>nom responsable enquete</td>
      <td><label>
        <input name="respenquete" type="text" id="respenquete" value="<%= dmxSetValue("", FormRequest("respenquete")) %>" />
      </label></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap>email responsable enquete</td>
      <td><label>
        <input name="email" type="text" id="email" value="<%= dmxSetValue("", FormRequest("email")) %>" />
      </label>
      <% dmxval1.GenerateError "formulaire1","email","allformats",",," %></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap>telephone responsable enquete</td>
      <td><label>
        <input name="tel" type="text" id="tel" value="<%= dmxSetValue("", FormRequest("tel")) %>" />
      </label></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap>&nbsp;</td>
      <td><input name="submit" type="submit" value="Ins&eacute;rer l'enregistrement" /></td>
    </tr>
  </table>
  <br />
creer un champ login aleatoire idem pwd
<input type="hidden" name="MM_insert" value="formulaire1" />
</form>
<p>&nbsp;</p>
</body>
</html>
<
%Recordset1.Close()
Set Recordset1 = Nothing
%>
<
%academie.Close()
Set academie = Nothing
%>


Replies

Replied 29 Oct 2009 12:29:14
29 Oct 2009 12:29:14 Patrick Julicher replied:
Hi Stephan,

Thank you for the source code. However, it would be easier if you'd also post a link to your testpage so we might be able to do some checking.

Kind regards, Patrick

Replied 29 Oct 2009 12:57:09
29 Oct 2009 12:57:09 stephan ludovic replied:
Hi Patrick,

I can't send you the test URL, i'm working on my local server for the moment.

But i identified the source of the problem.

It seems to happen when i applied the extension to a form with a insert field with values from recordset ( dropdownlist).

After applied the extension i always have to set the values of this dropdown list again...

Any idea?

Or is it a bug?

Thanks a lot
Replied 29 Oct 2009 13:05:45
29 Oct 2009 13:05:45 Patrick Julicher replied:
Hi Stephan,

I will try to rebuilt your situation with that dropdown list and see what happens.

Kind regards, Patrick
Replied 29 Oct 2009 13:10:08
29 Oct 2009 13:10:08 stephan ludovic replied:
Nice to you Patrick.

If this can help you, you will find bellow the asp code for the dropdownlis before and after applying the extension:

(dw cs4, asp, sql server)

Before:
 <select name="acetablist" id="acetablist">
          <
%While (NOT academie.EOF)
%>
          <option value="<%=(academie.Fields.Item("idacademie").Value)%>" <%If (Not isNull((academie.Fields.Item("idacademie").Value))) Then If (CStr(academie.Fields.Item("idacademie").Value) = CStr((academie.Fields.Item("idacademie").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%> ><%=(academie.Fields.Item("academie").Value)%></option>
          <
%  academie.MoveNext()
Wend
If (academie.CursorType > 0) Then
  academie.MoveFirst
Else
  academie.Requery
End If
%>
        </select>



After
<select name="acetablist" id="acetablist">
          <
%While (NOT academie.EOF)
%>
          <option <%= dmxSetSelectOption("<%=(academie.Fields.Item("idacademie").Value)%>",FormRequest("acetablist"),false) %> value="<%=(academie.Fields.Item("idacademie").Value)%>"
          <%If (Not isNull((academie.Fields.Item("idacademie").Value))) Then If (CStr(academie.Fields.Item("idacademie").Value) = CStr((academie.Fields.Item("idacademie").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>
><%=(academie.Fields.Item("academie").Value)%></option>
<
%  academie.MoveNext()
Wend
If (academie.CursorType > 0) Then
  academie.MoveFirst
Else
  academie.Requery
End If
%>
        </select>
Replied 29 Oct 2009 13:29:22
29 Oct 2009 13:29:22 Patrick Julicher replied:
Hi Stephan,

First, next time you paste source code, please also use the CODE-button (<> to prevent those smileys from popping up.
Now, change your code to this and let me know if that works:
select name="acetablist" id="acetablist">   
          <   
%While (NOT academie.EOF)   
%>   
          <option <%= dmxSetSelectOption((academie.Fields.Item("idacademie").Value),FormRequest("acetablist"),false) %> value="<%=(academie.Fields.Item("idacademie").Value)%>"  
          <%If (Not isNull((academie.Fields.Item("idacademie").Value))) Then If (CStr(academie.Fields.Item("idacademie").Value) = CStr((academie.Fields.Item("idacademie").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>   
><%=(academie.Fields.Item("academie").Value)%></option>   
<   
%  academie.MoveNext()   
Wend   
If (academie.CursorType > 0) Then  
  academie.MoveFirst   
Else  
  academie.Requery   
End If  
%>   
        </select>

Kind regards, Patrick
Replied 29 Oct 2009 13:40:24
29 Oct 2009 13:40:24 stephan ludovic replied:
Thanks it works fine.


But will i have to change the code to all my froms after applied the extension?

Replied 29 Oct 2009 13:42:23
29 Oct 2009 13:42:23 Patrick Julicher replied:
Hi Stephan,

I'm testing right now! Please be patient.

Kind regards, Patrick
Replied 29 Oct 2009 14:21:20
29 Oct 2009 14:21:20 Patrick Julicher replied:
Hi Stephan,

Please check your e-mail. Let me know if this fixes you problem.

Kind regards, Patrick
Replied 05 Nov 2009 00:21:21
05 Nov 2009 00:21:21 Patrick Julicher replied:
Hi Stephan,

Can you confirm that your problem was solved with the update?

KInd regards, Patrick
Replied 05 Nov 2009 09:20:00
05 Nov 2009 09:20:00 stephan ludovic replied:
Sorry,

It seems to work now but i will do some tests today.

Regards.
L Stephan
Replied 05 Nov 2009 11:06:01
05 Nov 2009 11:06:01 Patrick Julicher replied:
Hi Stephan,

I'm looking forward to your findings.

Kind regards, Patrick

Reply to this topic