Groups | Blog | Home
all groups > inetserver asp general > june 2005 >

inetserver asp general : checking for nothing entered in an asp form post


wk6pack
6/30/2005 4:00:38 PM
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

Bob Barrows [MVP]
6/30/2005 7:14:34 PM
[quoted text, click to view]

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

if len(lservice) > 0 then


Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Roland Hall
7/1/2005 1:07:20 AM
[quoted text, click to view]
:
: 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

Bullschmidt
7/5/2005 11:31:30 AM
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...


AddThis Social Bookmark Button