Print Page | Close Window

ASP Help

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=9532
Printed Date: 01 April 2026 at 1:00am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ASP Help
Posted By: Tegwin
Subject: ASP Help
Date Posted: 04 February 2004 at 8:56am

I am a newbie to ASP and I am writing an ASP script, with the help of the tutorials on this website (thanks borg). I would like to be able to make some fields mandatory, so that if someone presses submit, then it will not allow them to continue if they dont enter any info. At the moment if you press submit, it will enter blank entries into the database, and I do not want this to happen.

This is the code that writes into the db, what do I need to add to make the fields mandatory.

 

rsAddAssets.AddNew

'Add a new record to the recordset
rsAddAssets.Fields("FullName") = Request.Form("FullName")
rsAddAssets.Fields("MachineMake") = Request.Form("MachineMake")
rsAddAssets.Fields("MachineType") = Request.Form("MachineType")
rsAddAssets.Fields("SerialNum") = Request.Form("SerialNum")
rsAddAssets.Fields("AssetNum") = Request.Form("AssetNum")
rsAddAssets.Fields("Location") = Request.Form("location")
rsAddAssets.Fields("Notes") = Request.Form("Notes")


'Write the updated recordset to the database
rsAddAssets.Update

Any ideas will be appreciated

 



-------------
If you dont want my peaches, dont shake my tree



Replies:
Posted By: Anakin
Date Posted: 04 February 2004 at 10:06am

I don't know about an SQL-database, but if you are using an Access-database, you can make the fields mandatory inside the database.

You could also build your code so that your form (I take it you're using a form to enter the data) will not send anything to the database unless all fields have something in them.



Posted By: Tegwin
Date Posted: 04 February 2004 at 10:24am

I have made the fields mandatory, but when I dothat is errors out because the script will try and put a blank value into the DB.

Quote

You could also build your code so that your form (I take it you're using a form to enter the data) will not send anything to the database unless all fields have something in them.

I know HOW to do it in theory, but how do I CODE this.

 



-------------
If you dont want my peaches, dont shake my tree


Posted By: Semikolon
Date Posted: 04 February 2004 at 10:27am

yo tegwin! you could use a javascript form validation, or check the form fields in asp before adding to the database..

pm me if you need any help! (this is not in general for all users, Tegwin is a good friend)



Posted By: Bullschmidt
Date Posted: 05 February 2004 at 6:27am

Here are some validation resources for you:

Server-Side Form Validation by Dianna Leech - 12/1/1999
http://www.4guysfromrolla.com/webtech/120199-1.shtml - http://www.4guysfromrolla.com/webtech/120199-1.shtml

An Email Validation Routine by Joćo Vieira - 4/11/1999
http://www.4guysfromrolla.com/webtech/041199-1.shtml - http://www.4guysfromrolla.com/webtech/041199-1.shtml
Somewhat shorter.

An Email Validation Script by Ben Durbin - 5/19/1999
http://www.4guysfromrolla.com/webtech/051999-1.shtml - http://www.4guysfromrolla.com/webtech/051999-1.shtml
Longer.

Form Handler: Some light form validation and error notification.
http://www.asp101.com/samples/form_handler.asp - http://www.asp101.com/samples/form_handler.asp

Javascript Field Validations -- Client Side Scripting by Nannette Thacker - 8/19/1999
http://www.shiningstar.net/articles/articles/javascript/javascriptvalidations.asp?ID=AW - http://www.shiningstar.net/articles/articles/javascript/java scriptvalidations.asp?ID=AW

Form Validation Using Javascript - 9/19/1998
http://www.4guysfromrolla.com/webtech/091998-1.shtml - http://www.4guysfromrolla.com/webtech/091998-1.shtml
Good tips such as saving JavaScript functions in a file called DataValidation.js and including this in pages that need this.
JavaScript functions.

WebDaily: Your daily source for Web Technology Tips and Tricks! - 10/27/1998
http://www.4guysfromrolla.com/webtech/102798-1.shtml - http://www.4guysfromrolla.com/webtech/102798-1.shtml
Just checks if fields filled in.

Form Validation Scripts
http://www.coolnerds.com/jscript/formval.htm - http://www.coolnerds.com/jscript/formval.htm



-------------
J. Paul Schmidt, Freelance ASP Web Developer
www.Bullschmidt.com - www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Sample (Freely Downloadable)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net