![]() |
data entry validation
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/resource...Validation.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 |
| All times are GMT. The time now is 09:56 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.