Results 1 to 2 of 2

Thread: Urgent please

  1. #1
    Ajay Verma Guest

    Urgent please


    I wan to make a Genelarized Server Side Validations!
    Actually
    I'll make One asp page for validations
    and include in an every form(asp) page!
    But the Problem is that:
    After filling the complete information in the form then action
    should goes on different page how is it :
    Please send me Urgent soln
    user filling after all the data in the form fields
    action page remains not working properly!
    For eg:

    form2.asp

    <!-- #INCLUDE FILE=&#34;validateform.asp&#34;-->
    <html>
    <head>
    <title>Simple HTML Form</title>
    </head>
    <body>
    <form method=&#34;post&#34; action=&#34;form2.asp&#34; id=form1 name=form1>
    <input name=&#34;formScript&#34; type=&#34;hidden&#34; value=&#34;<%=Request.ServerVariables(&#34;SCRIPT_ NAME&#34%>&#34;>
    <b>Please enter your Name: </b>
    <input name=&#34;username&#34; type=&#34;text&#34; size=30 value=&#34;<%=Server.HTMLEncode( Request.Form( &#34;username&#34 )%>&#34;>
    <input name=&#34;username_req&#34; type=&#34;hidden&#34; value=&#34;You must enter a User name.&#34;>
    <p>
    <b>Please enter your Phone Number: </b>
    <input name=&#34;PhoneNumber&#34; type=&#34;text&#34; size=30 value=&#34;<%=Server.HTMLEncode(Request.Form( &#34;PhoneNumber&#34 )%>&#34;>
    <input name=&#34;PhoneNumber_req&#34; type=&#34;hidden&#34; value=&#34;You must enter a Phone Number.&#34;>
    <input name=&#34;PhoneNumber_val&#34; type=&#34;hidden&#34; value=&#34;number&#34;>
    <p>
    <b>Please enter your Date of birth: </b>
    <input name=&#34;birthdate&#34; type=&#34;text&#34; size=10 value=&#34;<%=Server.HTMLEncode( Request.Form( &#34;birthdate&#34 )%>&#34;>
    <input name=&#34;birthdate_req&#34; type=&#34;hidden&#34; value=&#34;You must enter your date of birth.&#34;>
    <input name=&#34;birthdate_val&#34; type=&#34;hidden&#34; value=&#34;date&#34;>
    <p>
    <b>Please enter your Email Address: </b>
    <input name=&#34;Email&#34; type=&#34;text&#34; size=10 value=&#34;<%=Server.HTMLEncode( Request.Form( &#34;email&#34 )%>&#34;>
    <input name=&#34;Email_req&#34; type=&#34;hidden&#34; value=&#34;You must enter your email.&#34;>
    <input name=&#34;Email_val&#34; type=&#34;hidden&#34; value=&#34;Email&#34;>
    <p>
    <input type=&#34;submit&#34; value=&#34;Save&#34;>
    <input type=&#34;reset&#34; value=&#34;reset&#34;>
    </form>
    </body>
    </html>


    Validateform.asp

    <%
    &#39;==================================
    &#39; INCLUDE FILE FOR FORM VALIDATION
    &#39;==================================
    &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;
    &#39; DECLARE GLOBAL VARIABLES
    &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;
    DIM errorMSG
    Dim chk
    validateForm
    IF errorMSG <> &#34;&#34; THEN errorForm
    &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;
    &#39; VALIDATE FORM
    &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;
    SUB validateForm
    DIM fieldAttrib,fieldName
    FOR EACH element IN Request.Form
    fieldAttrib=UCASE( RIGHT( element, 4))
    fieldName = LEFT( element, LEN( element ) - 4)
    IF fieldAttrib = &#34;_REQ&#34; AND Request.Form( fieldName ) = &#34;&#34; THEN
    errorMSG = errorMSG & &#34; - &#34; & Request.Form( element ) & &#34;<p>&#34;
    END IF
    IF fieldAttrib = &#34;_VAL&#34; AND Request.Form( fieldName ) <> &#34;&#34; THEN
    SELECT CASE UCASE( Request.Form( element ) )
    CASE &#34;NUMBER&#34;
    IF NOT isNumeric( Request.Form( fieldName ) ) THEN
    errorMSG = errorMSG & &#34; - &#34; & fieldName & &#34; must be a number.<p>&#34;
    END IF
    CASE &#34;DATE&#34;
    IF NOT isDATE( Request.Form( fieldName ) ) THEN
    errorMSG = errorMSG & &#34; - &#34; & fieldName & &#34; must be a date.<p>&#34;
    END IF
    CASE &#34;CURRENCY&#34;
    IF NOT isNumeric( Request.Form( fieldName ) ) THEN
    errorMSG = errorMSG & &#34; - &#34; & fieldName & &#34; must be a money amount.<p>&#34;
    END IF
    CASE &#34;EMAIL&#34;
    IF INSTR(Request.Form(fieldname),&#34;@&#34= 0 or instr(Request.Form(fieldname),&#34;.&#34=0 then
    errorMSG = errorMSG & &#34; - &#34; & fieldName & &#34; must be a email address.<p>&#34;
    end if
    END SELECT
    END IF
    NEXT
    END SUB
    &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;
    &#39; ERROR FORM
    &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;
    SUB errorFORM
    %>
    <html>
    <head><title>Error Form</title></head>
    <body>
    <b>There was a problem with the information you entered:</b>
    <blockquote>
    <%=errorMSG %>
    </body>
    </html>
    <%
    &#39;Response.End
    END SUB

    &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&# 39;
    &#39; DUMP ALL OF THE FORM FIELDS
    &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&# 39;

    SUB formFields
    DIM element, fieldAttrib
    FOR EACH element IN Request.Form
    fieldAttrib = UCASE( RIGHT( element, 4 ) )
    IF fieldAttrib <> &#34;_REQ&#34; AND fieldAttrib <> &#34;_VAL&#34; THEN
    %>
    <input name=&#34;<%=element%>&#34; type=&#34;hidden&#34; value=&#34;<%=Server.HTMLEncode( Request.Form( element ) )%>&#34;>
    <%
    END IF
    NEXT
    END SUB
    %>

    Ajay Verma


  2. #2
    Frank Kwong Guest

    Urgent please (reply)

    Check out www.aspdb.com front page o fsite and go into SuperValidator.

    FK


    ------------
    Ajay Verma at 5/3/01 6:03:48 AM


    I wan to make a Genelarized Server Side Validations!
    Actually
    I&#39;ll make One asp page for validations
    and include in an every form(asp) page!
    But the Problem is that:
    After filling the complete information in the form then action
    should goes on different page how is it :
    Please send me Urgent soln
    user filling after all the data in the form fields
    action page remains not working properly!
    For eg:

    form2.asp

    <!-- #INCLUDE FILE=&#34;validateform.asp&#34;-->
    <html>
    <head>
    <title>Simple HTML Form</title>
    </head>
    <body>
    <form method=&#34;post&#34; action=&#34;form2.asp&#34; id=form1 name=form1>
    <input name=&#34;formScript&#34; type=&#34;hidden&#34; value=&#34;<%=Request.ServerVariables(&#34;SCRIPT_ NAME&#34%>&#34;>
    <b>Please enter your Name: </b>
    <input name=&#34;username&#34; type=&#34;text&#34; size=30 value=&#34;<%=Server.HTMLEncode( Request.Form( &#34;username&#34 )%>&#34;>
    <input name=&#34;username_req&#34; type=&#34;hidden&#34; value=&#34;You must enter a User name.&#34;>
    <p>
    <b>Please enter your Phone Number: </b>
    <input name=&#34;PhoneNumber&#34; type=&#34;text&#34; size=30 value=&#34;<%=Server.HTMLEncode(Request.Form( &#34;PhoneNumber&#34 )%>&#34;>
    <input name=&#34;PhoneNumber_req&#34; type=&#34;hidden&#34; value=&#34;You must enter a Phone Number.&#34;>
    <input name=&#34;PhoneNumber_val&#34; type=&#34;hidden&#34; value=&#34;number&#34;>
    <p>
    <b>Please enter your Date of birth: </b>
    <input name=&#34;birthdate&#34; type=&#34;text&#34; size=10 value=&#34;<%=Server.HTMLEncode( Request.Form( &#34;birthdate&#34 )%>&#34;>
    <input name=&#34;birthdate_req&#34; type=&#34;hidden&#34; value=&#34;You must enter your date of birth.&#34;>
    <input name=&#34;birthdate_val&#34; type=&#34;hidden&#34; value=&#34;date&#34;>
    <p>
    <b>Please enter your Email Address: </b>
    <input name=&#34;Email&#34; type=&#34;text&#34; size=10 value=&#34;<%=Server.HTMLEncode( Request.Form( &#34;email&#34 )%>&#34;>
    <input name=&#34;Email_req&#34; type=&#34;hidden&#34; value=&#34;You must enter your email.&#34;>
    <input name=&#34;Email_val&#34; type=&#34;hidden&#34; value=&#34;Email&#34;>
    <p>
    <input type=&#34;submit&#34; value=&#34;Save&#34;>
    <input type=&#34;reset&#34; value=&#34;reset&#34;>
    </form>
    </body>
    </html>


    Validateform.asp

    <%
    &#39;==================================
    &#39; INCLUDE FILE FOR FORM VALIDATION
    &#39;==================================
    &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;
    &#39; DECLARE GLOBAL VARIABLES
    &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;
    DIM errorMSG
    Dim chk
    validateForm
    IF errorMSG <> &#34;&#34; THEN errorForm
    &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;
    &#39; VALIDATE FORM
    &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;
    SUB validateForm
    DIM fieldAttrib,fieldName
    FOR EACH element IN Request.Form
    fieldAttrib=UCASE( RIGHT( element, 4))
    fieldName = LEFT( element, LEN( element ) - 4)
    IF fieldAttrib = &#34;_REQ&#34; AND Request.Form( fieldName ) = &#34;&#34; THEN
    errorMSG = errorMSG & &#34; - &#34; & Request.Form( element ) & &#34;<p>&#34;
    END IF
    IF fieldAttrib = &#34;_VAL&#34; AND Request.Form( fieldName ) <> &#34;&#34; THEN
    SELECT CASE UCASE( Request.Form( element ) )
    CASE &#34;NUMBER&#34;
    IF NOT isNumeric( Request.Form( fieldName ) ) THEN
    errorMSG = errorMSG & &#34; - &#34; & fieldName & &#34; must be a number.<p>&#34;
    END IF
    CASE &#34;DATE&#34;
    IF NOT isDATE( Request.Form( fieldName ) ) THEN
    errorMSG = errorMSG & &#34; - &#34; & fieldName & &#34; must be a date.<p>&#34;
    END IF
    CASE &#34;CURRENCY&#34;
    IF NOT isNumeric( Request.Form( fieldName ) ) THEN
    errorMSG = errorMSG & &#34; - &#34; & fieldName & &#34; must be a money amount.<p>&#34;
    END IF
    CASE &#34;EMAIL&#34;
    IF INSTR(Request.Form(fieldname),&#34;@&#34= 0 or instr(Request.Form(fieldname),&#34;.&#34=0 then
    errorMSG = errorMSG & &#34; - &#34; & fieldName & &#34; must be a email address.<p>&#34;
    end if
    END SELECT
    END IF
    NEXT
    END SUB
    &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;
    &#39; ERROR FORM
    &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;
    SUB errorFORM
    %>
    <html>
    <head><title>Error Form</title></head>
    <body>
    <b>There was a problem with the information you entered:</b>
    <blockquote>
    <%=errorMSG %>
    </body>
    </html>
    <%
    &#39;Response.End
    END SUB

    &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&# 39;
    &#39; DUMP ALL OF THE FORM FIELDS
    &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39; &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;&# 39;

    SUB formFields
    DIM element, fieldAttrib
    FOR EACH element IN Request.Form
    fieldAttrib = UCASE( RIGHT( element, 4 ) )
    IF fieldAttrib <> &#34;_REQ&#34; AND fieldAttrib <> &#34;_VAL&#34; THEN
    %>
    <input name=&#34;<%=element%>&#34; type=&#34;hidden&#34; value=&#34;<%=Server.HTMLEncode( Request.Form( element ) )%>&#34;>
    <%
    END IF
    NEXT
    END SUB
    %>

    Ajay Verma


Posting Permissions

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