Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - ASP Help
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ASP Help

 Post Reply Post Reply
Author
Tegwin View Drop Down
Senior Member
Senior Member


Joined: 03 September 2003
Location: United Kingdom
Status: Offline
Points: 430
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tegwin Quote  Post ReplyReply Direct Link To This Post Topic: ASP Help
    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
Back to Top
Anakin View Drop Down
Newbie
Newbie
Avatar

Joined: 27 January 2004
Location: Belgium
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote Anakin Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
Tegwin View Drop Down
Senior Member
Senior Member


Joined: 03 September 2003
Location: United Kingdom
Status: Offline
Points: 430
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tegwin Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post 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)

Back to Top
Bullschmidt View Drop Down
Groupie
Groupie


Joined: 31 May 2003
Location: United States
Status: Offline
Points: 72
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bullschmidt Quote  Post ReplyReply Direct Link To This Post 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

An Email Validation Routine by Joćo Vieira - 4/11/1999
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
Longer.

Form Handler: Some light form validation and error notification.
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/java scriptvalidations.asp?ID=AW

Form Validation Using Javascript - 9/19/1998
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
Just checks if fields filled in.

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



Edited by Bullschmidt
J. Paul Schmidt, Freelance ASP Web Developer
www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Sample (Freely Downloadable)
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.