Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form validation

Status
Not open for further replies.

HaveTrouble

Programmer
Jan 10, 2005
63
0
0
US
What's the best way to do dynamic format validation ? I have an ASP (page1.asp) that can be accessed by multiple clients and a setting page for clients to define which fields on page1.asp is mandatory. What's the best way to do this kind of form validation ?
 
Are you talking about client-side or server-side validation?

Doing validation on the client is nice because the user doesn't need make the round trip to the server only to find out that required fields were missing.

Doing validation on the server important if there is any incentive for the user to submit malformed information... (shopping cart, online test, etc...) or if you have database or other back-end requirements that require certain key field values.
 
We only need to make sure the field is filled, does not care the format of the data. However, we need to allow customer to define with fields they want to make mandatory. The only way I can think of is to store the fieldname selected by customer in a table. On page1.asp, build javascript according to the fieldname in the table. Is there better way to do it ?
 
If your site already uses a database for other reasons then this is a fine approach. If this is the only reason to use a database then i would instead consider using a text file. Perhaps just a config file that you read in the Application_OnStart() event in your global.asa
 
Is there any sample page that I can refer to using application_onstart() for form validation ?
 
I meant just using the application_onstart to do your configuration.... the stuff that only has to happen once per instance of your web app.

I am assuming that this is a web app that is sold to your clients for them to run on their own machines?
 
No. The web app is on our server. All customers are accessing the same web app and that's why our ASP must be able to configure depending on which customer logins at the time.
 
Ah, so you won't know which configuration to use until the user submits their logon credentials?

Perhaps each client could have a custom validation script and then, in the login page, you could put the name of the script into a session variable?

Or, if it is more than one form to validate, put the name of the client into the session variable and add conditionals to the server-side script in each form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top