Bruce Gust
asked on
If isempty - inserting &nbsp into a database
You would this this would be a no-brainer, but I'm having difficulty...
If the user leaves a field blank, I want to insert " " into the database. No big deal. Problem is, I must have it scripted incorrectly because what I have returns absolutely nothing.
Take a look:
if NOT isempty (Request.Form("BusName")) then
x = Replace(Request.Form("BusN ame"),"'", "''")
else
x = "Hello"
end if
response.write x
When Request.Form("BusName") is empty, while there's no error on the page, "x" doesn't register at all. I get a blank page as opposed to "Hello".
What am I missing?
If the user leaves a field blank, I want to insert " " into the database. No big deal. Problem is, I must have it scripted incorrectly because what I have returns absolutely nothing.
Take a look:
if NOT isempty (Request.Form("BusName")) then
x = Replace(Request.Form("BusN
else
x = "Hello"
end if
response.write x
When Request.Form("BusName") is empty, while there's no error on the page, "x" doesn't register at all. I get a blank page as opposed to "Hello".
What am I missing?
Sorry, I meant :
if Request.Form("BusName")<>" " then
if Request.Form("BusName")<>"
david_barker is correcet, however, i would use
If Len(Trim(Request.Form("Bus Name"))) > 0 Then....
incase users insert spaces into 'blank' fields e.t.c
If Len(Trim(Request.Form("Bus
incase users insert spaces into 'blank' fields e.t.c
ASKER
scanadmin...
You've got my vote, friend. Thank you both for taking the time to help me out. David, your suggestion worked, but scanadmin is anticipating some user error and I'm thinking that's wise.
scanadmin, could you please explain to me "Len". I've never seen that before and I would be interested in knowing what it's doing from a code perspective.
Thanks!
You've got my vote, friend. Thank you both for taking the time to help me out. David, your suggestion worked, but scanadmin is anticipating some user error and I'm thinking that's wise.
scanadmin, could you please explain to me "Len". I've never seen that before and I would be interested in knowing what it's doing from a code perspective.
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if Request.Form("BusName")=""