checking for nothing entered in an asp form post

W

wk6pack

Hi,

How do you check for a empty value from a form?

lservice = request.form("pservice")

if not isnull(lservice) then <== this doesnt work.
tried "" empty string and it still didnt work.
......

I'm having problems with the fact the user didnt enter anything. The field
is optional.

thanks,
Will
 
B

Bob Barrows [MVP]

wk6pack said:
Hi,

How do you check for a empty value from a form?

lservice = request.form("pservice")

if not isnull(lservice) then <== this doesnt work.
tried "" empty string and it still didnt work.
.....

I'm having problems with the fact the user didnt enter anything. The
field is optional.

thanks,
Will

form and querystring variables contain strings, so just check the number of
characters:

if len(lservice) > 0 then


Bob Barrows
 
R

Roland Hall

in message : How do you check for a empty value from a form?
:
: lservice = request.form("pservice")
:
: if not isnull(lservice) then <== this doesnt work.
: tried "" empty string and it still didnt work.
: .....
:
: I'm having problems with the fact the user didnt enter anything. The
field
: is optional.

This works also:

if lserver <> "" then
' value present
else
' no value present
end if

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
B

Bullschmidt

And here are some server-side validation links:

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
Uses function to loop thru all fields in a form.

And some client-side ones:

Javascript Field Validations -- Client Side Scripting by Nannette
Thacker - 8/19/1999
http://www.shiningstar.net/articles/articles/javascript/javascriptvalida
tions.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.

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top