Hello. I am using Classic ASP VBScript. I am testing server-side validation with a small, 2-field form. I think I may be on the right track, but I'm unsure how to separate the 2 fields and I would like to retain the entered value for the correct field when the page displays error for the incorrect field. It is validating for a numeric entry on both fields.
Here's a link to the form: <
www.lghmedia.com/test/test_form.asp>
2 files: <test_form.asp> and <test_form_process.asp>.
"Test_form.asp" has 2 fields: {numProd, numVend}.
The "test_form.asp" file submits to "test_form_process.asp" for validation. I created a separate "IF...THEN" statement for each form field which redirect back to the "form_test.asp" page with a respective variable if not validated:
==========================
==========
==========
==========
=
<% If Not IsNumeric(Request.Form("nu
mProd")) Then
Response.Redirect("test_fo
rm.asp?err
or=numProd
notnumeric
")
END IF
%>
<% If Not IsNumeric(Request.Form("nu
mVend")) Then
Response.Redirect("test_fo
rm.asp?err
or=numVend
notnumeric
")
END IF
%>
==========================
==========
==========
==========
=
==========================
==========
==========
==========
=
Here is the code for the error messages to display on "test_form.asp"
==========================
==========
==========
==========
=
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
<% If Request.QueryString("error
") = "numProdnotnumeric" Then %>
<tr>
<td colspan="2"><font color="#FF0000">Please enter a quantity of products.</font></td>
</tr>
<%END IF%>
<tr>
<td width="120">Number Products:</td>
<td width="280"><input name="numProd" type="text" id="numProd" size="30"></td>
</tr>
<% If Request.QueryString("error
") = "numVendnotnumeric" Then %>
<tr>
<td colspan="2"><font color="#FF0000">Please enter a quantity of vendors.</font></td>
</tr>
<%END IF%>
<tr>
<td>NumberVendors:</td>
<td><input name="numVend" type="text" id="numVend" size="30"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
==========================
==========
==========
==========
=
==========================
==========
==========
==========
=
1) How can I get the display for each invalid field?
2) After being redirected due to an invalid entry, how can I get the fields to retain the entries that were made?
Thanks so much,
Shane
Start Free Trial