data entry validation

Discussion in 'ASP General' started by Gary D. Rezek, Apr 8, 2004.

  1. Hi All,
    I'm trying to make an .asp include for form data entry validation. I found Ken Schaefer's site
    http://www.adopenstatic.com/resources/code/UIValidation.asp
    and am *just* trying to learn how to write javascript using vbscript so I don't know if
    what I have for **Sub WriteFormFooter()** at the bottom of this post is correct in its syntax.
    I know the input form's data is reaching these subs but when I leave an input text box blank
    I do not get a pop-up telling me. So I am assuming that I have written that Sub wrong.

    <%
    ********************
    ' Accepts strFunctionName as string - Name of javascript function
    '----------------------------------------
    Sub WriteFormHeader(ByVal strFunctionName)
    With Response
    .Write(" <script type=""text/javascript"">") & vbCrLf
    .Write(" <!--") & vbCrLf
    .Write(" function " & strFunctionName & "(theForm)" & vbCrLf)
    .Write(" {") & vbCrLf
    End With
    End Sub ' WriteFormHeader
    ********************
    ' Accepts strFieldName as string -Name of the field to validate
    ' Accepts strDisplayName as string - Name of the field to be used in the
    ' alert message you want to pop up
    ' Writes javascript to pop up a javascript alert box if nothing is entered into the field
    '----------------------------------------
    Sub WriteFormFieldTextRequired(ByVal strFieldName, ByVal strDisplayName)
    With Response
    .Write(" // " & strDisplayName & " - Start" & vbCrLf)
    .Write(" if (theForm." & strFieldName & ".value== """")" & vbCrLf)
    .Write(" {" & vbCrLf)
    .Write(" alert(""Please enter a value for the \""" & strDisplayName & "\"" field."");" & vbCrLf)
    .Write(" theForm." & strFieldName & ".focus();" & vbCrLf)
    .Write(" return (false);") & vbCrLf
    .Write(" }") & vbCrLf
    .Write(" // " & strDisplayName & " - End" & vbCrLf)
    End With
    End Sub
    ********************
    Sub WriteFormFooter()
    With Response
    .Write(" }") & vbCrLf
    .Write(" // -->") & vbCrLf
    .Write( "</script>")
    End With
    End Sub
    '-----------------------------------------
    %>

    I call these subs from the data entry page like so:

    Call WriteFormHeader("Form1Validator")
    Call WriteFormFieldTextRequired("strStudentIDNumber", "Student ID Number")
    <<I have 4 other of the same type calls here>>
    Call WriteFormFooter()

    And the form tag reads thus:

    <form action="default.asp" method="post" id="PreReg" name="PreReg" onSubmit="return Form1Validator(this)">

    Would someone please help me to correct it?
    Thanks in advance.

    gdr
    --
    Gary D. Rezek
    University Networking Systems and Services
    South Dakota State University
    Gary D. Rezek, Apr 8, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sviau
    Replies:
    1
    Views:
    374
    Steven Cheng[MSFT]
    Mar 3, 2004
  2. bienwell
    Replies:
    0
    Views:
    3,394
    bienwell
    Nov 17, 2005
  3. AtomicBob
    Replies:
    14
    Views:
    871
    Toby Inkster
    May 2, 2006
  4. Mike Owen

    Allowing entry of a Carriage Return during data entry

    Mike Owen, Jul 27, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    696
    Alessandro Zifiglio
    Jul 27, 2006
  5. Noozer
    Replies:
    2
    Views:
    251
    Dr John Stockton
    Aug 1, 2005
Loading...

Share This Page