DwZone Forum DwZone Forum
Welcome to the DwZone-it Forum
 
  FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups  
    RegisterRegister -->   LoginLogin  
Server Side Validation  
DwZone Forum Index -> Server Side Validation

Moderators: AdministratorsModerators 
Hint: For improved responsiveness, use Internet Explorer 4 (or above) with Javascript enabled, choose 'Dynamic' from the View dropdown and hit 'Set Options' to save your changes.
New Topic Search for
 View     Per page     Messages Since 
Messages 31 to 40 of 85 (Total: 33) First |  Prev |  Next |  Last  
 Subject Author Date  
   Re:Acceptable Characters  
View this persons public profile  gianluigi   14:24 4 Aug 2008  
   Re:Acceptable Characters  
View this persons public profile  [email protected]   14:29 4 Aug 2008  
   Re:Acceptable Characters  
View this persons public profile  gianluigi   9:54 5 Aug 2008  
   Re:Acceptable Characters  
View this persons public profile  [email protected]   10:19 5 Aug 2008  
    Here the code  
View this persons public profile  [email protected]   14:51 3 Jun 2008  
 
Hi
Thanks for the reply.
I need some basic steps. The server validator is not working
below is my form with your asp code at the top. The next part is the asp code page
you can see my link here www.c-photos.co.uk

------------------------my form-----------------------------

<%@LANGUAGE="VBSCRIPT"%>
<%
'******************************
' http://www.DwZone-it.com
' Server Side Form Validator
' Version 1.1.9
'******************************
Dim dwzValidator_0
Set dwzValidator_0 = new dwzServerSideValidator
dwzValidator_0.SetFormName "contact_form"
dwzValidator_0.SetMainMessage "The form contains errors or is incomplete"
dwzValidator_0.SetCodeBefore ""
dwzValidator_0.SetCodeAfter ""
dwzValidator_0.SetClassName "None"
dwzValidator_0.SetJsAlert "N"
dwzValidator_0.SetReturnMethod "POST"
dwzValidator_0.SetImageError ""
dwzValidator_0.SetRedirect "", "2"
dwzValidator_0.init()
dwzValidator_0.add "Digital_Vs_Films", "select", "--", "NotFirst", ",", "The field ''Digital_Vs_Films'' is not valid"
dwzValidator_0.add "Which_SLR", "select", "--", "NotFirst", ",", "The field ''Which_SLR'' is not valid"
dwzValidator_0.add "Which_Medium_Format", "select", "--", "NotFirst", ",", "The field ''Which_Medium_Format'' is not valid"
dwzValidator_0.add "Which_Large_Format", "select", "--", "NotFirst", ",", "The field ''Which_Large_Format'' is not valid"
dwzValidator_0.add "Digital_Back", "select", "--", "NotFirst", ",", "The field ''Digital_Back'' is not valid"
dwzValidator_0.add "Digital_equipment", "select", "--", "NotFirst", ",", "The field ''Digital_equipment'' is not valid"
dwzValidator_0.add "System_that_you_use", "select", "--", "NotFirst", ",", "The field ''System_that_you_use'' is not valid"
dwzValidator_0.add "Another_system", "select", "--", "NotFirst", ",", "The field ''Another_system'' is not valid"
dwzValidator_0.add "Digital_assistant", "select", "--", "NotFirst", ",", "The field ''Digital_assistant'' is not valid"
dwzValidator_0.add "Shoot_solution_perfect", "textarea", "Yes", "Any", ",,", "The field ''Shoot_solution_perfect'' is not valid"
dwzValidator_0.add "IIdiko_Emma", "select", "--", "NotFirst", ",", "The field ''IIdiko_Emma'' is not valid"
dwzValidator_0.add "Agreed_TC", "select", "--", "NotFirst", ",", "The field ''Agreed_TC'' is not valid"
dwzValidator_0.add "Name", "text", "Yes", "Alphabetic", ",", "The field ''Name'' is not valid"
dwzValidator_0.add "email", "text", "Yes", "Mail", ",", "The field ''email'' is not valid"
dwzValidator_0.add "contact", "text", "Yes", "Integer,0,9", "", "The field ''contact'' is not valid"
dwzValidator_0.add "recipient", "hidden", "Yes", "Alphabetic", ",", "The field ''recipient'' is not valid"
dwzValidator_0.add "subject", "hidden", "Yes", "Alphabetic", ",", "The field ''subject'' is not valid"
dwzValidator_0.validate()
'******************************
' http://www.DwZone-it.com
' Server Side Form Validator
' End code
'******************************
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Win a free digital shoot package - Republik</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/tex.css" rel="stylesheet" type="text/css">

</head>
<body bgcolor="#000000">
<form action="" method="post" name="contact_form" id="contact_form" >
<table width="907" border="0" align="center" cellspacing="10">
<tr>
<td colspan="3"><div align="center"><img src="rimag/logo1.jpg" alt="republik logo" width="292" height="292"></div></td>
</tr>
<tr>
<td colspan="3"><div align="center"><img src="rimag/tag.jpg" alt="Photographer's questionnaire" width="412" height="32"></div></td>
</tr>
<tr>
<td colspan="3"><img src="rimag/win.jpg" alt="win free digital shoot package" width="866" height="46"></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr class="BigWhite">
<td colspan="3">1. How frequently would you say you shoot Digital Vs Films?</td>
</tr>
<tr class="BigWhite">
<td colspan="3">
<select name="Digital_Vs_Films" id="Digital_Vs_Films">
<option value="""">Please choose one of the following options:</option>
<option value="I only shoot digital (1)">I only shoot digital</option>
<option value="I only shoot film (4)">I only shoot film</option>
<option value="I shoot more digital than film (2)">I shoot more digital
than film</option>
<option value="I shoot more film than digita l(3)">I shoot more film
than digital</option>
</select></td>
</tr>
<tr class="BigWhite">
<td colspan="2">2. Which camera would system(s) do you mainly work with?</td>
<td width="34"> </td>
</tr>
<tr class="BigWhite">
<td colspan="3">
<table width="100%" border="0" cellspacing="0" class="BigWhite">
<tr>
<td width="64"><div align="right">SLR:</div></td>
<td width="142"><select name="Which_SLR" id="Which_SLR">
<option value="""" selected>--- Select ---</option>
<option value="Canon (1)">Canon </option>
<option value="Nikon (2)">Nikon</option>
<option value="Other SLR (3)">Other SLR</option>
<option value="None (0)">None </option>
</select></td>
<td width="153"><div align="right">Medium Format:</div></td>
<td width="122"><select name="Which_Medium_Format" id="Which_Medium_Format">
<option value="""" selected>--- Select ---</option>
<option value="Contax (3)">Contax</option>
<option value="Hasselblad (1)">Hasselblad</option>
<option value="Mamiya (2)">Mamiya</option>
<option value="None (0)">None</option>
</select></td>
<td width="172"><div align="right">Large Format:</div></td>
<td width="220"><select name="Which_Large_Format" id="Which_Large_Format">
<option value="""">--- Select ---</option>
<option value="Cambo (3)">Cambo</option>
<option value="Linhof (1)">Linhof</option>
<option value="Sinar (2)">Sinar</option>
<option value="None (0)">None</option>
</select></td>
</tr>
</table></td>
</tr>
<tr class="BigWhite">
<td colspan="2">3. If you shoot medium format digital, which brand of digital
back do you use?</td>
<td> </td>
</tr>
<tr class="BigWhite">
<td colspan="2">
<select name="Digital_Back" id="Digital_Back">
<option value="""">Please choose one of the following options:</option>
<option value="Leaf (3)">Leaf</option>
<option value="Hasselbad (2)">Hasselbad</option>
<option value="Phaseone (1)">Phaseone</option>
<option value="Other (4)">Other</option>
</select></td>
<td> </td>
</tr>
<tr class="BigWhite">
<td colspan="2">4. Do you own any digital equipment?</td>
<td> </td>
</tr>
<tr class="BigWhite">
<td colspan="2">
<select name="Digital_equipment" id="Digital_equipment">
<option value="""">Please choose one of the following options:</option>
<option value="Yes, I own a digital back (3)">Yes, I own a digital back</option>
<option value="Yes, I own a digital camera (2)">Yes, I own a digital
camera</option>
<option value="No, I hire digital equipment(1)">No, I hire digital equipment</option>
</select></td>
<td> </td>
</tr>
<tr class="BigWhite">
<td colspan="2">5. Why did you choose the particular digital system that
you use?</td>
<td> </td>
</tr>
<tr class="BigWhite">
<td height="27" colspan="2">
<select name="System_that_you_use" id="System_that_you_use">
<option value="""">Please choose one of the following options:</option>
<option value="I tested several options myself to find the best solution to suit my needs (1)">I
tested several options myself to find the best solution to suit my needs</option>
<option value="My current system came highly recommend and I am happy so far (1)">My
current system came highly recommend and I am happy so far</option>
<option value="I chose my digital workflow based on the availability and/or cost of the equipment (1)">I
chose my digital workflow based on the availability and/or cost of the
equipment</option>
</select></td>
<td> </td>
</tr>
<tr class="BigWhite">
<td colspan="2">6. Would you consider trying a digital system with one of
our digital operators for FREE? If so, which one?<br></td>
<td> </td>
</tr>
<tr class="BigWhite">
<td colspan="2">
<select name="Another_system" id="Another_system">
<option value="""">Please choose one of the following options:</option>
<option value="SLR Systems Canon 1DS MkIII (4)">SLR Systems Canon 1DS
MkIII</option>
<option value="Medium format with Hasselblad digital back (3)">Medium
format with Hasselblad digital back</option>
<option value="Medium format with PhaseOne digital back (1)">Medium
format with PhaseOne digital back</option>
<option value="Medium format with Leaf digital back (5)">Medium format
with Leaf digital back</option>
<option value="Large format with Phaseone back (2)">Large format with
Phaseone back</option>
</select></td>
<td> </td>
</tr>
<tr class="BigWhite">
<td colspan="2">7. Do you use a digital assistant on shoots?</td>
<td> </td>
</tr>
<tr class="BigWhite">
<td colspan="2">
<select name="Digital_assistant" id="Digital_assistant">
<option value="""">Please choose one of the following options:</option>
<option value=" No, I shoot by myself (3)">No, I shoot by myself</option>
<option value="Yes, I use my normal photographic assistant (2)">Yes,
I use my normal photographic assistant </option>
<option value=" Yes, I use a professional digital operator (1)">Yes,
I use a professional digital operator</option>
</select></td>
<td> </td>
</tr>
<tr class="BigWhite">
<td colspan="2">8. Republik offers tailor made digital solutions for both
location and studio shoots <br>
If cost were not an issue, what would make your shoot solution perfect?<br></td>
<td> </td>
</tr>
<tr class="BigWhite">
<td colspan="2">
<textarea name="Shoot_solution_perfect" cols="50" rows="15" id="Shoot_solution_perfect"></textarea></td>
<td> </td>
</tr>
<tr class="BigWhite">
<td colspan="2">9. Would you like Ildiko or Emma to create the perfect digital
shoot for you?</td>
<td> </td>
</tr>
<tr class="BigWhite">
<td colspan="2">
<select name="IIdiko_Emma" id="IIdiko_Emma">
<option value="""">Please choose one of the following options:</option>
<option value="I am very interested">I am very interested</option>
<option value="I might be interested">I might be interested</option>
</select></td>
<td> </td>
</tr>
<tr class="BigWhite">
<td colspan="2"> 10. *Terms and conditions of competitions</td>
<td> </td>
</tr>
<tr class="BigWhite">
<td colspan="2"> <table width='61%' border='0' cellpadding='4' cellspacing='0' >
<tr bgcolor='#ffffff'>
<td align=center ><div align="left" class="tc">Read terms and conditions
</div>
<p align="left" class="tc">a) Photographic shoot must be taken within
3 months from draw date.<br>
b) Shoot date is subject to availability.<br>
c) 14 days notice must be given before scheduled shoot date.<br>
d) reserves the right to postpone or cancel the shoot date. <br>
e) All additional items of travel, delivery & collection and overtime
are charged. <br>
f) Free shoot period is for one day, standard working hours 9am-6pm.
<br>
g) Consumable items are subject to charge. <br>
h) If Photographer/winner cancels or postpones shoot date without
adequate notice will result in forfeit of shoot package prize.
<br>
i) � Terms and Conditions� Apply. See staff for details. </p>
<p></p></td>
</tr>
<tr>
<td align=center bgcolor='#f1f1f1'><font face='verdana' size='2'><span class="tc">
Do you agree to our terms and conditions?</span> </font> <select name="Agreed_TC" id="Agreed T&C">
<option value="""">-- Select --</option>
<option value="Yes">Yes</option>
</select> <font face='verdana' size='2'>  </font><font face='verdana' size='2'> 
</font></td>
</tr>
<tr bgcolor='#ffffff'>
<td align=center > </td>
</tr>
</table>
</td>
<td> </td>
</tr>
<tr class="BigWhite">
<td width="116">

Name:
</td>
<td width="711">
<input name="Name" type="text" id="Name"></td>
<td> </td>
</tr>
<tr class="BigWhite">
<td>Email: </td>
<td>
<input name="email" type="text" id="email"></td>
<td> </td>
</tr>
<tr class="BigWhite">
<td>Website:</td>
<td>
<input name="website" type="text" id="website"></td>
<td> </td>
</tr>
<tr class="BigWhite">
<td>Contact no:</td>
<td>
<input name="contact" type="text" id="contact" maxlength="11"></td>
<td> </td>
</tr>
<tr class="BigWhite">
<td> </td>
<td>
<input type=submit value=Submit></td>
<td> </td>
</tr>
<tr>
<td colspan="2"> </td>
<td> </td>
</tr>
</table>
<input name="recipient" type="hidden" id="recipient" value="[email protected]">
<input name="subject" type="hidden" id="subject" value="Republik - Photographer's questionnaire">
<input type="hidden" id="dwzServerValidate" name="dwzServerValidate" value="contact_form" />
</form>
</body>
</html>
<!--#include file="./dwzValidator/dwzValidatorClass.asp" -->
<%
'******************************
' http://www.DwZone-it.com
' Server Side Form Validator
'******************************
response.write(dwzValidator_0.getJsAlert())
set dwzValidator_0 = nothing
'******************************
' http://www.DwZone-it.com
' Server Side Form Validator
'******************************
%>
--------------------------------your asp code-----------------------------------
<%
'**********************************
' http://www.DwZone-it.com
' Server Side Form Validator
' Copyright (c) DwZone.it 2000-2005
'**********************************
class dwzServerSideValidator

Private MainMessage
Private FormName
Private CodeBefore
Private CodeAfter
Private ClassName
Private sIsValid
Private ImageError
Private sReturnMethod
Private JsAlert
Private FormSendMethod
Private RedirectPage
Private RedirectMethod

Private ItemFieldName()
Private ItemFieldType()
Private ItemRequired()
Private ItemValidate()
Private ItemFieldLength()
Private ItemErrorMessage()
Private ItemValid()

Private ItemCount

Public isPostBack
Public isReturnBack


public sub SetRedirect(param_1, param_2)
RedirectPage = param_1
RedirectMethod = param_2
end sub

public sub SetMainMessage(param)
MainMessage = param
end sub

public sub SetFormName(param)
FormName = param
end sub

public sub SetCodeBefore(param)
CodeBefore = param
end sub

public sub SetCodeAfter(param)
CodeAfter = param
end sub

public sub setImageError(param)
ImageError = param
end sub

public sub SetClassName(param)
ClassName = param
end sub

public sub SetReturnMethod(param)
sReturnMethod = Ucase(param)
end sub

public sub SetJsAlert(param)
JsAlert = param
end sub

Public sub add(sFieldName, sFieldType, sRequired, sValidate, sFieldLength, sErrMessage)
ItemCount = ItemCount + 1
ReDim Preserve ItemFieldName(ItemCount)
ReDim Preserve ItemFieldType(ItemCount)
ReDim Preserve ItemRequired(ItemCount)
ReDim Preserve ItemValidate(ItemCount)
ReDim Preserve ItemFieldLength(ItemCount)
ReDim Preserve ItemErrorMessage(ItemCount)
ReDim Preserve ItemValid(ItemCount)

ItemFieldName(ItemCount) = sFieldName
ItemFieldType(ItemCount) = sFieldType
ItemRequired(ItemCount) = sRequired
ItemValidate(ItemCount) = sValidate
ItemFieldLength(ItemCount) = sFieldLength
ItemErrorMessage(ItemCount) = sErrMessage
ItemValid(ItemCount) = true
end sub


Private Sub Class_Initialize()
End Sub

Private Sub Class_Terminate()
End Sub

Public Sub Init ()

CT = Request.ServerVariables("HTTP_Content_Type")
if len(CT) = 0 then CT = Request.ServerVariables("CONTENT_TYPE")
If LCase(Left(CT, 19)) = "multipart/form-data" Then
response.Clear()
response.write("WARNING!!<br>")
response.write("http://www.dwzone-ir.com<br>")
response.write("The Server Side Form Validtaion is not compatible width the enctype of the form<br>")
response.write("If this is an upload page use a different form validator method<br>")
response.End()
Exit sub
End If

ItemCount = -1
if request("dwzServerValidate")<>"" and lcase(request("dwzServerValidate")) = lcase(FormName) then
isPostBack = true
else
isPostBack = false
end if
sIsValid = true
if request("dvzValidateBack")<>"" then
isReturnBack = true
else
isReturnBack = false
end if

FormSendMethod = UCase(Request.ServerVariables("REQUEST_METHOD"))

End Sub

Public Sub Validate()

if request("dvzValidateBack")<>"" then
RecreateValidation()
exit sub
end if

if not isPostBack then
exit sub
end if

if lcase(Request.ServerVariables("HTTP_Content_Type")) = "multipart/form-data" then
response.Clear()
msg = "WARNING!!<BR>"
msg = msg & "The form ENCTYPE is setup to multipart/form-data<BR>"
msg = msg & "This Form Validator don't work with this ENCTYPE<br>"
msg = msg & "Please remove the ENCTYPE before use this validator<br>"
response.write(msg)
response.End()
end if

for K=0 to ItemCount
select case lcase(ItemFieldType(K))
case "textarea"
ValidateTextArea(K)
case "checkbox"
ValidateCheckBox(K)
case "chk group"
ValidateChkGroup(K)
case "radio"
ValidateRadio(K)
case "select"
ValidateSelect(K)
case else
ValidateText(K)
end select
next

sIsValid = true
for J=0 to ItemCount
if not ItemValid(J) then
sIsValid = false
exit for
end if
next

if not sIsValid then
ReturnBack()
else
if RedirectPage<>"" then
if RedirectMethod="0" then
response.Redirect(RedirectPage)
elseif RedirectMethod="1" then
RedirectWithPost()
else
server.Transfer(RedirectPage)
end if
response.End()
end if
end if
end sub

public function getSummary()
dim retStr
retStr = ""
if not sIsValid then
for J=0 to ItemCount
if not ItemValid(J) then
tmp = CodeBefore & ItemErrorMessage(J) & CodeAfter
if ClassName <> "" then
tmp = "<div class='" & ClassName & "'>" & tmp & "</div>"
else
tmp = tmp & "<br>"
end if
retStr = retStr & tmp
end if
next
if retStr <> "" then
tmp = CodeBefore & MainMessage & CodeAfter
if ClassName <> "" then
tmp = "<div class='" & ClassName & "'>" & tmp & "</div>"
else
tmp = tmp & "<br><br>"
end if
retStr = tmp & retStr
end if
end if
response.write(retStr)
end function

public function getMainMessage()
dim retStr
retStr = ""
if not sIsValid then
tmp = CodeBefore & MainMessage & CodeAfter
if ClassName <> "" then
tmp = "<div class='" & ClassName & "'>" & tmp & "</div>"
else
tmp = tmp & "<br><br>"
end if
retStr = tmp & retStr
end if
response.write(retStr)
end function

public function getJsAlert()
dim retStr
retStr = ""
if JsAlert <> "N" then
for J=0 to ItemCount
if not ItemValid(J) then
retStr = retStr & replaceForJs(ItemErrorMessage(J)) & "\n"
end if
next
if retStr <> "" then
retStr = "<script language=javascript>alert('" & replaceForJs(MainMessage) & "\n\n" & retStr & "')</script>"
end if
end if
getJsAlert = retStr
end function

private function replaceForJs(str)
replaceForJs = replace(replace(str,chr(34),"''"),"'","\u0027")
end function

public function getTextErrMsg(fldName)
dim retStr
id = getIndex(fldName)
retStr = " "
if id <> -1 then
if not ItemValid(id) then
retStr = CodeBefore & ItemErrorMessage(id) & CodeAfter
if ClassName <> "" then
retStr = "<div class='" & ClassName & "'>" & retStr & "</div>"
end if
end if
end if
response.write(retStr)
end function

public function getImageErrMsg(fldName)
dim retStr
id = getIndex(fldName)
retStr = " "
if id <> -1 then
if not ItemValid(id) then
retStr = "<img src='" & ImageError & "' border='0' alt='" & replace(replace(ItemErrorMessage(id),"'",""),chr(34),"") & "' />"
end if
end if
response.write(retStr)
end function

private function getIndex(fld)
dim retStr
retStr = -1
for J=0 to ItemCount
if lcase(ItemFieldName(J)) = lcase(fld) then
retStr = J
exit for
end if
next
getIndex = retStr
end function

private sub RecreateValidation()
if request("dvzValidateResult")="" then
exit sub
end if
tmp = split(request("dvzValidateResult"),"@_dwz_@")
for J=0 to ubound(tmp)
for K=0 to ItemCount
if lcase(ItemFieldName(K)) = lcase(tmp(J)) then
'response.write K
'response.End()
ItemValid(K) = false
sIsValid = false
exit for
end if
next
next
end sub


private sub RedirectWithPost()
response.Clear()
response.write("<html><body>" & vbcrlf)
response.write("<form style='visibility:hidden' name='dwzForm' id='dwzForm' method='POST' action='" & RedirectPage & "' >" & vbcrlf)
if FormSendMethod = "POST" then
for each Key in request.Form
if lcase(Key)<>lcase("dwzServerValidate") and lcase(Key)<>lcase("dvzValidateBack") and left(lcase(Key),3)<>"mm_" and lcase(Key)<>lcase("dvzValidateResult") then
response.write("<TEXTAREA id='" & Key & "' name='" & Key & "' >" & request(Key) & "</TEXTAREA>" & vbcrlf)
end if
next
else
for each Key in request.QueryString
if lcase(Key)<>lcase("dwzServerValidate") and lcase(Key)<>lcase("dvzValidateBack") and left(lcase(Key),3)<>"mm_" and lcase(Key)<>lcase("dvzValidateResult") then
response.write("<TEXTAREA id='" & Key & "' name='" & Key & "' >" & request(Key) & "</TEXTAREA>" & vbcrlf)
end if
next
end if
response.write("</form>" & vbcrlf)
response.write("<script language=javascript>document.getElementById('dwzForm').submit()</script>" & vbcrlf)
response.write("</body></html>")
response.End()
end sub



private sub ReturnBack()
if sReturnMethod <> "POST" and sReturnMethod <> "GET" then
exit sub
end if
response.Clear()
response.write("<html><body>" & vbcrlf)
FormTag = "<form style='visibility:hidden' name='dwzForm' id='dwzForm' method='" & sReturnMethod & "' action='" & CStr(Request.ServerVariables("SCRIPT_NAME"))
if FormSendMethod = "POST" then
if request.QueryString<>"" then
FormTag = FormTag & "?" & request.QueryString
end if
end if
FormTag = FormTag & "' >" & vbcrlf
response.write(FormTag)
if FormSendMethod = "POST" then
for each Key in request.Form
if lcase(key)<>lcase("DW_Form_Name") and lcase(Key)<>lcase("dwzServerValidate") and lcase(Key)<>lcase("dvzValidateBack") and left(lcase(Key),3)<>"mm_" and lcase(Key)<>lcase("dvzValidateResult") then
response.write("<TEXTAREA id='" & Key & "' name='" & Key & "' >" & request(Key) & "</TEXTAREA>" & vbcrlf)
end if
next
else
for each Key in request.QueryString
if lcase(key)<>lcase("DW_Form_Name") and lcase(Key)<>lcase("dwzServerValidate") and lcase(Key)<>lcase("dvzValidateBack") and left(lcase(Key),3)<>"mm_" and lcase(Key)<>lcase("dvzValidateResult") then
response.write("<TEXTAREA id='" & Key & "' name='" & Key & "' >" & request(Key) & "</TEXTAREA>" & vbcrlf)
end if
next
end if
response.write("<INPUT type='hidden' id='dvzValidateResult' name='dvzValidateResult' value='" & getValidateResult() & "' />" & vbcrlf)
response.write("<INPUT type='hidden' id='dvzValidateBack' name='dvzValidateBack' value='1' />" & vbcrlf)
response.write("</form>" & vbcrlf)
response.write("<script language=javascript>document.getElementById('dwzForm').submit()</script>" & vbcrlf)
response.write("</body></html>")
response.End()
end sub

Public Function isValid()
isValid = sIsValid
end function

Public Function showRegion(formName,boolValue)
if isPostBack or isReturnBack then
select case boolValue
case "0"
if isValid() then
showRegion = false
else
showRegion = true
end if
case else
if isValid() then
showRegion = true
else
showRegion = false
end if
end select
else
showRegion = false
end if
end function

Private Function getValidateResult()
dim retStr
retStr = ""
cong = ""
for J=0 to ItemCount
if not ItemValid(J) then
retStr = retStr & cong & ItemFieldName(J)
cong = "@_dwz_@"
end if
next
getValidateResult = retStr
end function


private function ValidateText(index)
if ItemRequired(index)="Yes" and left(ItemValidate(index),11)<>"One of them" then
if request(ItemFieldName(index)) = "" then
ItemValid(index) = false
exit function
end if
end if
fldValue = request(ItemFieldName(index))
if ItemFieldLength(index) <> "," and ItemFieldLength(index) <> "" then
tmp = split(ItemFieldLength(index), ",")
if tmp(0)<>"" and isNumeric(tmp(0)) then
if len(fldValue) < clng(tmp(0)) then
ItemValid(index) = false
exit function
end if
end if
if tmp(1)<>"" and isNumeric(tmp(1)) then
if len(fldValue) > clng(tmp(1)) then
ItemValid(index) = false
exit function
end if
end if
end if

Set RegEx = New RegExp
RegEx.Global = True
RegEx.IgnoreCase = True

if fldValue = "" then
ItemValid(index) = true
exit function
end if

if ItemValidate(index) = "Alphanumeric" then
RegEx.Pattern = "^[A-Za-z0-9]*$"
if not RegEx.test(fldValue) then
ItemValid(index) = false
exit function
end if

elseif ItemValidate(index) = "Alphabetic" then
RegEx.Pattern = "^[A-Za-z]*$"
if not RegEx.test(fldValue) then
ItemValid(index) = false
exit function
end if

elseif left(ItemValidate(index),7) = "Integer" then
RegEx.Pattern = "^-?[0-9]*$"
if not RegEx.test(fldValue) then
ItemValid(index) = false
exit function
end if
tmp = split(ItemValidate(index) ,",")
if tmp(1)<>"" and isNumeric(tmp(1)) then
if clng(tmp(1)) > clng(fldValue) then
ItemValid(index) = false
exit function
end if
end if
if tmp(2)<>"" and isNumeric(tmp(2)) then
if clng(tmp(2)) < clng(fldValue) then
ItemValid(index) = false
exit function
end if
end if

elseif left(ItemValidate(index),5) = "Float" then
RegEx.Pattern = "^-?[0-9]+[\.]*[0-9]*$"
if not RegEx.test(fldValue) then
ItemValid(index) = false
exit function
end if
tmp = split(ItemValidate(index) ,",")
if tmp(1)<>"" and isNumeric(tmp(1)) then
if cdbl(tmp(1)) > cdbl(replace(fldValue,".",",")) then
ItemValid(index) = false
exit function
end if
end if
if tmp(2)<>"" and isNumeric(tmp(2)) then
if cdbl(tmp(2)) < cdbl(replace(fldValue,".",",")) then
ItemValid(index) = false
exit function
end if
end if

elseif left(ItemValidate(index),10) = "AcceptChar" then
tmp = split(ItemValidate(index) ,",")
RegEx.Pattern = "^[" & tmp(1) & "]*$"
if not RegEx.test(fldValue) then
ItemValid(index) = false
exit function
end if

elseif left(ItemValidate(index),12) = "unAcceptChar" then
tmp = split(ItemValidate(index) ,",")
RegEx.Pattern = "^[^" & tmp(1) & "]*$"
if not RegEx.test(fldValue) then
ItemValid(index) = false
exit function
end if

elseif left(ItemValidate(index),6) = "RegExp" then
pos_1 = instr(ItemValidate(index),",")
pos_2 = instrRev(ItemValidate(index),",")
pattern = mid(ItemValidate(index), pos_1+1, pos_2-pos_1-1)
flag = mid(ItemValidate(index), pos_2+1)
RegEx.Global = false
RegEx.IgnoreCase = false
'"g","i","gi","g-rev","i-rev","gi-rev","rev"
select case flag
case "g", "g-rev"
RegEx.Global = true
case "i","i-rev"
RegEx.IgnoreCase = true
case "gi", "gi-rev", "rev"
RegEx.Global = true
RegEx.IgnoreCase = true
end select
RegEx.Pattern = pattern
if not RegEx.test(fldValue) then
ItemValid(index) = false
exit function
end if

elseif ItemValidate(index) = "Mail" then
RegEx.Pattern = "^[\w\.=-]+@[\w\.-]+\.[a-z]{2,4}$"
if not RegEx.test(fldValue) then
ItemValid(index) = false
exit function
end if

elseif left(ItemValidate(index),4) = "Date" then
tmp = split(ItemValidate(index) ,",")
dateFormat = tmp(1)
select case dateFormat
case "DD.MM.YYYY", "DD/MM/YYYY", "DD-MM-YYYY"
myDate = split(fldValue, mid(dateFormat,3,1))
if ubound(myDate) <> 2 then
ItemValid(index) = false
exit function
end if
if not isNumeric(myDate(0)) or not isNumeric(myDate(1)) or not isNumeric(myDate(2)) then
ItemValid(index) = false
exit function
end if
myDay = myDate(0)
myMonth = myDate(1)
myYear = myDate(2)

case "MM.DD.YYYY", "MM/DD/YYYY", "MM-DD-YYYY":
myDate = split(fldValue, mid(dateFormat,3,1))
if ubound(myDate) <> 2 then
ItemValid(index) = false
exit function
end if
if not isNumeric(myDate(0)) or not isNumeric(myDate(1)) or not isNumeric(myDate(2)) then
ItemValid(index) = false
exit function
end if
myDay = myDate(1)
myMonth = myDate(0)
myYear = myDate(2)

case "YYYY-MM-DD", "YYYY/MM/DD", "YYYY.MM.DD"
myDate = split(fldValue, mid(dateFormat,5,1))
if ubound(myDate) <> 2 then
ItemValid(index) = false
exit function
end if
if not isNumeric(myDate(0)) or not isNumeric(myDate(1)) or not isNumeric(myDate(2)) then
ItemValid(index) = false
exit function
end if
myDay = myDate(2)
myMonth = myDate(1)
myYear = myDate(0)

end select
'DateSerial(Year, Month, Day)
newDate = DateSerial(myYear,myMonth,myDay)
if clng(Year(newDate))<>clng(myYear) or clng(month(newDate))<>clng(myMonth) or clng(day(newDate))<>clng(myDay) then
ItemValid(index) = false
exit function
end if

elseif left(ItemValidate(index),4) = "Time" then
tmp = split(ItemValidate(index) ,",")
select case tmp(1)
case "12:00"
RegEx.Pattern = "^\(0[0-2]|1[0-2]|0?[0-9]\)\:\([0-5][0-9]\)$"
case "12:00pm"
RegEx.Pattern = "^\(0[0-2]|1[0-2]|0?[0-9]\)\:\([0-5][0-9]\)\(p|a\)m$"
case "24:00"
RegEx.Pattern = "^\(0[0-9]|1[0-9]|2[0-3]\)\:\([0-5][0-9]\)$"
end select
if not RegEx.test(fldValue) then
ItemValid(index) = false
exit function
end if

elseif left(ItemValidate(index),8) = "Equal to" then
tmp = split(ItemValidate(index) ,",")
if fldValue <> "" and request(tmp(1)) <> fldValue then
ItemValid(index) = false
exit function
end if

elseif left(ItemValidate(index),7) = "Compare" then
tmp = split(ItemValidate(index) ,",")
if fldValue <> "" then
select case tmp(1)
case "1"
if lcase(fldValue) <> lcase(Application(tmp(2)) & "") then
ItemValid(index) = false
exit function
end if
case "2"
if lcase(fldValue) <> lcase(Session(tmp(2)) & "") then
ItemValid(index) = false
exit function
end if
case "3"
if lcase(fldValue) <> lcase(request.Cookies(tmp(2)) & "") then
ItemValid(index) = false
exit function
end if
end select
end if
elseif left(ItemValidate(index),11) = "One of them" then
tmp = split(ItemValidate(index) ,",")
fieldValid = false
for J=1 to ubound(tmp)
if request(tmp(J))<>"" then
fieldValid = true
exit for
end if
next
if not fieldValid then
ItemValid(index) = false
exit function
end if
elseif left(ItemValidate(index),3) = "Any" then

else
response.Clear()
response.write("Non riconosciuto: " & ItemFieldName(index) & " " & ItemFieldType(index) & " " & ItemValidate(index))
response.End()
end if
end function


public function getFieldValue(defaultValue,fieldName,formName)
if isPostBack or isReturnBack then
getFieldValue = request(fieldName)
else
getFieldValue = defaultValue
end if
end function

private function ValidateTextArea(index)
if ItemRequired(index) = "Yes" then
if request(ItemFieldName(index)) = "" then
ItemValid(index) = false
exit function
end if
end if

if request(ItemFieldName(index)) = "" then
ItemValid(index) = true
exit function
end if

tmp = split(ItemFieldLength(index), ",")
fldValue = request(ItemFieldName(index))

if tmp(2)="Y" and fldValue<>"" then
fldValue = RemoveHTML(fldValue)
end if

if tmp(0)<>"" and isNumeric(tmp(0)) then
if len(fldValue) < clng(tmp(0)) then
ItemValid(index) = false
exit function
end if
end if

if tmp(1)<>"" and isNumeric(tmp(1)) then
if len(fldValue) > clng(tmp(1)) then
ItemValid(index) = false
exit function
end if
end if
end function


private function ValidateCheckBox(index)
if ItemValidate(index) = "Must" then
if request(ItemFieldName(index)) = "" then
ItemValid(index) = false
exit function
end if
end if
if left(ItemValidate(index),6) = "filled" and request(ItemFieldName(index)) <> "" then
tmp = split(ItemValidate(index), ",")
if request(tmp(1)) = "" then
ItemValid(index) = false
exit function
end if
end if
end function


private function ValidateChkGroup(index)
fld = split(ItemValidate(index), ",")
groupValid = false
if left(ItemValidate(index),3) = "One" then
for J=0 to ubound(fld)
if request(fld(J))<>"" then
groupValid = true
exit for
end if
next
if not groupValid then
ItemValid(index) = false
exit function
end if
end if

if left(ItemValidate(index),9) = "ChkMinMax" and ItemFieldLength(index)<>"," then
tmp = split(ItemFieldLength(index), ",")
sel = 0
for J=0 to ubound(fld)
if request(fld(J))<>"" then
sel = sel + 1
end if
next
if tmp(0)<>"" and isNumeric(tmp(0)) then
if sel < clng(tmp(0)) then
ItemValid(index) = false
exit function
end if
end if
if tmp(1)<>"" and isNumeric(tmp(1)) then
if sel > clng(tmp(1)) then
ItemValid(index) = false
exit function
end if
end if
end if
end function


private function ValidateRadio(index)
if ItemValidate(index) = "One" then
if request(ItemFieldName(index)) = "" then
ItemValid(index) = false
exit function
end if
end if
if left(lcase(ItemValidate(index)),6) = "filled" and request(ItemFieldName(index)) <> "" then
tmp = split(ItemValidate(index), ",")
if request(tmp(1)) = "" then
ItemValid(index) = false
exit function
end if
end if
end function

private function ValidateSelect(index)
if ItemValidate(index) = "NotFirst" then
if request(ItemFieldName(index)) = "Null" or request(ItemFieldName(index)) = "" then
ItemValid(index) = false
exit function
end if
end if
if ItemValidate(index) = "SelMinMax" and request(ItemFieldName(index)) <> "" then
tmp = split(ItemFieldLength(index), ",")
val = split(request(ItemFieldName(index)), ",")
if tmp(0)<>"" and isNumeric(tmp(0)) then
if clng(Ubound(val)) < clng(tmp(0)) then
ItemValid(index) = false
exit function
end if
end if
if tmp(1)<>"" and isNumeric(tmp(1)) then
if clng(Ubound(val)) > clng(tmp(1)) then
ItemValid(index) = false
exit function
end if
end if
end if
end function


private function RemoveHTML(str)
Set RegEx = New RegExp
RegEx.Pattern = "<[^>]*"
RegEx.Global = True
RegEx.IgnoreCase = True
str = RegEx.Replace(str, "")

Set RegEx = New RegExp
RegEx.Pattern = "&[\w]{1-6};"
RegEx.Global = True
RegEx.IgnoreCase = True
str = RegEx.Replace(str, "_")
RemoveHTML = str
end function


Public Function createDynamicCombo()
dim retStr
retStr = ""
if StaticOptionLabel<>"" and StaticOptionValue<>"" then
tmpLabel = split(StaticOptionLabel, "@_@")
tmpValue = split(StaticOptionValue, "@_@")
for J=0 to ubound(tmpLabel)
if isPostBack or isReturnBack then
if isOptionSelected(cstr(request(FieldName)), tmpValue(J)) then
sel = " SELECTED=" & chr(34) & "SELECTED" & chr(34)
else
sel = ""
end if
else
if isOptionSelected(ValueEqualTo, tmpValue(J)) then
sel = " SELECTED=" & chr(34) & "SELECTED" & chr(34)
else
sel = ""
end if
end if
retStr = retStr & "<option value='" & tmpValue(J) & "' " & sel & ">" & tmpLabel(J) & "</option>" & vbcrlf
next
end if
dwz_Recordset.requery
while not dwz_Recordset.eof
if isPostBack or isReturnBack then
if isOptionSelected(cstr(request(FieldName)), cstr(dwz_Recordset(ValueColumn))) then
sel = " SELECTED=" & chr(34) & "SELECTED" & chr(34)
else
sel = ""
end if
else
if isOptionSelected(cstr(dwz_Recordset(ValueColumn)), cstr(ValueEqualTo)) then
sel = " SELECTED=" & chr(34) & "SELECTED" & chr(34)
else
sel = ""
end if
end if
retStr = retStr & "<option value='" & dwz_Recordset(ValueColumn) & "' " & sel & ">" & dwz_Recordset(LabelColumn) & "</option>" & vbcrlf
dwz_Recordset.MoveNext
wend
response.write(retStr)
end function

public function createStaticCombo()
dim retStr
retStr = ""
if StaticOptionLabel<>"" and StaticOptionValue<>"" then
tmpLabel = split(StaticOptionLabel, "@_@")
tmpValue = split(StaticOptionValue, "@_@")
for J=0 to ubound(tmpLabel)
if isPostBack or isReturnBack then
if isOptionSelected(cstr(request(FieldName)), tmpValue(J)) then
sel = " SELECTED=" & chr(34) & "SELECTED" & chr(34)
else
sel = ""
end if
else
if isOptionSelected(cstr(ValueEqualTo), tmpValue(J)) then
sel = " SELECTED=" & chr(34) & "SELECTED" & chr(34)
else
sel = ""
end if
end if
retStr = retStr & "<option value='" & tmpValue(J) & "' " & sel & ">" & tmpLabel(J) & "</option>" & vbcrlf
next
end if
response.write(retStr)
end function

public function getCheckboxSelected(valore,checkIf,fieldName,formName)
dim retStr
retStr = ""
if isPostBack or isReturnBack then
if request(fieldName)<>"" then
retStr = " CHECKED "
end if
else
if cstr(valore)<>"" then
if checkIf <> "" then
if cstr(checkIf) = cstr(valore) then
retStr = " CHECKED "
end if
else
if valore then
retStr = " CHECKED "
end if
end if
end if
end if
getCheckboxSelected = retStr
end function

Public function getRadioSelected(valore,checkIf,fieldName,formName)
dim retStr
retStr = ""
if isPostBack or isReturnBack then
if cstr(request(fieldName)) = cstr(checkIf) then
retStr = " CHECKED "
end if
else
if cstr(valore & "")<>"" then
if cstr(checkIf) = cstr(valore) then
retStr = " CHECKED "
end if
end if
end if
getRadioSelected = retStr
end function

private function isOptionSelected(lista,valore)
dim retStr
retStr = false
if lista <> "" and valore <> "" then
tmp = split(lista,",")
for x=0 to ubound(tmp)
if trim(tmp(x)) = cstr(valore) then
retStr = true
exit for
end if
next
end if
isOptionSelected = retStr
end function



end class
%>
---------------------------------------- asp code end----------------------------------



 
Reply to this current thread  View this persons public profile  Send Private Message
   server validation not installing  
View this persons public profile  [email protected]   8:34 3 Jun 2008  
   Re:server validation not installing  
View this persons public profile  gianluigi   9:53 3 Jun 2008  
   Re:server validation not installing  
View this persons public profile  [email protected]   13:53 3 Jun 2008  
   Re:server validation not installing  
View this persons public profile  gianluigi   14:31 3 Jun 2008  
   Issues with textarea after validation  
View this persons public profile  [email protected]   13:02 27 May 2008  
Last Visit: Friday 17 May, 2024 0:54 pm First |  Prev |  Next |  Last  
 Login
Username:  Password:    
Read Message Read Message   Unread message Unread message
Read message [popular] Read message [popular]   Unread message [popular] Unread message [popular]
Read message [locked] Read message [locked]   Unread message [locked] Unread message [locked]
All times are GMT-2

Jump to: