[thelist] help with form validation using ASP/VBScript

VOLKAN ÖZÇELİK volkan.ozcelik at gmail.com
Tue Mar 1 01:05:23 CST 2005


Brian's approach will not work. Since it is client-side VBScript.

Here is what I will use in such a situation.

<%
Dim IsPostBack = (Request.Form.Count > 0)
Dim field1 = Request.Form("field1")
Dim blnErrorInField1 = False

If IsPostBack Then
	DoValidate
End If

Sub DoValidate
	'any validation logic on form fields.
	If field1.value <> "valid value" Then
		blnErrorInField1 = True
	End If
End Sub
%>
<html>
<head>
	<script type="text/javascript">
		var blnErrorInFied1 = "<%=blnErrorInField1%>";

		window.onload = function(e) {
			if(blnErrorInFied1.toLowerCase() == "true") {
				alert("Error in Field 1");
				document.forms[0].field1.focus();
			}
		}
	</script>
</head>
<body>
	<form id="FrmPage" method="post"
action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
		hello : <input type="text" name="field1" value="" />
	</form>
</body>
</html>

----
Matt Warden's article given is really nice.

In addition, if possible, consider migrating to ASP.NET, cuz in 2-3
year all the articles you fetch googling will be on ASP.NET.

Regards,
Volkan.


On Mon, 28 Feb 2005 19:57:20 -0500, Michele Foster (WizarDev)
<michele at wizardev.ca> wrote:
> 
> ----- Original Message -----
> From: "Pringle, Ron" <RPringle at aurora-il.org>
> >
> > So it appears that I'm left with sending the form to a validation page?
> >
> 
> Ron,
> 
> I highly recommend Matt's article, I've used the concepts presented for
> numerous applications
> 
> http://evolt.org/article/Writing_Smart_Web_based_Forms/17/10199/index.html
> 
> Holler if you need help .. :)
> 
> Mich
> 
> --
> 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>


More information about the thelist mailing list