Hi,
At the moment i am checking that all the fields have been filled out, at the
moment i am using the following...
if firstname = "" and surname = "" and address1 = "" and town = "" and
county = "" and country = "" and postcode = "" and phone = "" and email11 =
"" and email2 = "" and password1 = "" and password2 = "" then
is there a better more efficient way of doing this??
cheers,
gav 19 17149
You could concatenate them all:
sStringSum = firstname & surname & address1 & town & county & country &
postcode & phone & email11 & email2 & password1 & password2
If Len(Trim(sStringSum)) = 0 Then
Response.Write "You didn't fill in anything."
Response.End
End If
Ray at work
"Gav" <ga*****@ntlworld.com> wrote in message
news:8l******************@newsfep2-win.server.ntli.net... Hi, At the moment i am checking that all the fields have been filled out, at
the moment i am using the following...
if firstname = "" and surname = "" and address1 = "" and town = "" and county = "" and country = "" and postcode = "" and phone = "" and email11
= "" and email2 = "" and password1 = "" and password2 = "" then
is there a better more efficient way of doing this??
cheers, gav
That's how I do it, unfortunately.
Also, are you checking this on the client-side beforehand? It might be a
good idea to do some form validation using Javascript, first, so you save
yourself a trip to the server.
"Gav" <ga*****@ntlworld.com> wrote in message
news:8l******************@newsfep2-win.server.ntli.net... Hi, At the moment i am checking that all the fields have been filled out, at
the moment i am using the following...
if firstname = "" and surname = "" and address1 = "" and town = "" and county = "" and country = "" and postcode = "" and phone = "" and email11
= "" and email2 = "" and password1 = "" and password2 = "" then
is there a better more efficient way of doing this??
cheers, gav
This will only tell you that ALL the fields are empty. (if firstname is
blank *and* surname is blank *and*...)
I usually use client-side validation for this, I have a check for each form
field in JavaScript, and if any field is empty, the form doesn't get
submitted and they're asked to fill in the data. This way, the server
doesn't have to do any work checking, and the user is told immediately
instead of wasting time submitting data and waiting for the server to
respond. You also have an easier time keeping track of the data they've
filled in correctly, because you don't have to re-populate the form if it's
never been submitted.
Of course you check on the server as well, because some people don't allow
JavaScript for some reason. But you can save a lot of time and server
processing by stopping 99% of potential errors at the client.
"Gav" <ga*****@ntlworld.com> wrote in message
news:8l******************@newsfep2-win.server.ntli.net... Hi, At the moment i am checking that all the fields have been filled out, at
the moment i am using the following...
if firstname = "" and surname = "" and address1 = "" and town = "" and county = "" and country = "" and postcode = "" and phone = "" and email11
= "" and email2 = "" and password1 = "" and password2 = "" then
is there a better more efficient way of doing this??
cheers, gav
'Make sure none of the boxes are empty (zero length)
If len(firstname) = 0 or len(surname) = 0 or len(address1) = 0 or len(town)
= 0 or len(county) = 0 or len(country) = 0 or len(postcode) = 0 or
len(phone) = 0 or len(email11) = 0 or len(email2) = 0 or len(password1) = 0
or len(password2) = 0 Then
Using Len and "Or" instead of "And" is a much better way of doing it.
There's probably also a "cleaner" way of doing it..... I just can't think of
one at the moment.
--
Regards
Steven Burn
Ur I.T. Mate Group www.it-mate.co.uk
Keeping it FREE!
Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Gav <ga*****@ntlworld.com> wrote in message
news:8l******************@newsfep2-win.server.ntli.net... Hi, At the moment i am checking that all the fields have been filled out, at
the moment i am using the following...
if firstname = "" and surname = "" and address1 = "" and town = "" and county = "" and country = "" and postcode = "" and phone = "" and email11
= "" and email2 = "" and password1 = "" and password2 = "" then
is there a better more efficient way of doing this??
cheers, gav
Also, just to save you confusion in the future, null and empty string are
*NOT* the same thing.
\
"Gav" <ga*****@ntlworld.com> wrote in message
news:8l******************@newsfep2-win.server.ntli.net... Hi, At the moment i am checking that all the fields have been filled out, at
the moment i am using the following...
if firstname = "" and surname = "" and address1 = "" and town = "" and county = "" and country = "" and postcode = "" and phone = "" and email11
= "" and email2 = "" and password1 = "" and password2 = "" then
is there a better more efficient way of doing this??
cheers, gav
As much as I respect Ray, his solution would only work if
ALL the entries were blank. If even one of those had text,
then his test could produce a false positive.
Are you getting this from an HTML form somewhere? If you
are, then another way to do it (call me old fashioned) is
to use client-side script to validate the form entries
before the user even submits the form. Make their browser
do some of the work! -----Original Message----- You could concatenate them all:
sStringSum = firstname & surname & address1 & town &
county & country &postcode & phone & email11 & email2 & password1 &
password2 If Len(Trim(sStringSum)) = 0 Then Response.Write "You didn't fill in anything." Response.End End If
Ray at work
"Gav" <ga*****@ntlworld.com> wrote in message news:8l******************@newsfep2-win.server.ntli.net... Hi, At the moment i am checking that all the fields have
been filled out, atthe moment i am using the following...
if firstname = "" and surname = "" and address1 = ""
and town = "" and county = "" and country = "" and postcode = "" and
phone = "" and email11= "" and email2 = "" and password1 = "" and password2
= "" then is there a better more efficient way of doing this??
cheers, gav
.
Hi,
Thanks for all the replies!!! much apreaciated.
I've gone with stevens method, seems to be the tidyest.
As suggested im also going to use a client side check first to reduce the
load on the server
:)
"Steven Burn" <nobody@PVT_it-mate.co.uk> wrote in message
news:#s**************@TK2MSFTNGP11.phx.gbl... 'Make sure none of the boxes are empty (zero length) If len(firstname) = 0 or len(surname) = 0 or len(address1) = 0 or
len(town) = 0 or len(county) = 0 or len(country) = 0 or len(postcode) = 0 or len(phone) = 0 or len(email11) = 0 or len(email2) = 0 or len(password1) =
0 or len(password2) = 0 Then
Using Len and "Or" instead of "And" is a much better way of doing it. There's probably also a "cleaner" way of doing it..... I just can't think
of one at the moment.
-- Regards
Steven Burn Ur I.T. Mate Group www.it-mate.co.uk
Keeping it FREE!
Disclaimer: I know I'm probably wrong, I just like taking part ;o)
Gav <ga*****@ntlworld.com> wrote in message news:8l******************@newsfep2-win.server.ntli.net... Hi, At the moment i am checking that all the fields have been filled out, at the moment i am using the following...
if firstname = "" and surname = "" and address1 = "" and town = "" and county = "" and country = "" and postcode = "" and phone = "" and
email11 = "" and email2 = "" and password1 = "" and password2 = "" then
is there a better more efficient way of doing this??
cheers, gav
If your client side validation is tight enough, you really
shouldn't need to do much by way of server-side
validation. The only thing I use ASP for is functions that
JavaScript doesn't provide, such as Replace.
If you're worried about people disabling scripting, one
solution I've come up with is this:
<script language="JavaScript">
document.write("<input type=\"submit\"
value=\"Submit\">);
</script>
<noscript>
In order to submit this form, your browser must have
script enabled.
</noscript> -----Original Message----- Hi, Thanks for all the replies!!! much apreaciated.
I've gone with stevens method, seems to be the tidyest.
As suggested im also going to use a client side check
first to reduce theload on the server
:)
"Steven Burn" <nobody@PVT_it-mate.co.uk> wrote in message news:#s**************@TK2MSFTNGP11.phx.gbl... 'Make sure none of the boxes are empty (zero length) If len(firstname) = 0 or len(surname) = 0 or len
(address1) = 0 orlen(town) = 0 or len(county) = 0 or len(country) = 0 or len
(postcode) = 0 or len(phone) = 0 or len(email11) = 0 or len(email2) = 0
or len(password1) =0 or len(password2) = 0 Then
Using Len and "Or" instead of "And" is a much better
way of doing it. There's probably also a "cleaner" way of doing it.....
I just can't thinkof one at the moment.
-- Regards
Steven Burn Ur I.T. Mate Group www.it-mate.co.uk
Keeping it FREE!
Disclaimer: I know I'm probably wrong, I just like taking part ;o)
Gav <ga*****@ntlworld.com> wrote in message news:8liIb.471$Qr5.269154@newsfep2-
win.server.ntli.net... > Hi, > At the moment i am checking that all the fields have
been filled out, at the > moment i am using the following... > > if firstname = "" and surname = "" and address1 = ""
and town = "" and > county = "" and country = "" and postcode = "" and
phone = "" andemail11 = > "" and email2 = "" and password1 = "" and password2
= "" then > > is there a better more efficient way of doing this?? > > cheers, > gav > >
.
No problem.
--
Regards
Steven Burn
Ur I.T. Mate Group www.it-mate.co.uk
Keeping it FREE!
Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Gav <ga*****@ntlworld.com> wrote in message
news:qL******************@newsfep2-win.server.ntli.net... Hi, Thanks for all the replies!!! much apreaciated.
I've gone with stevens method, seems to be the tidyest.
As suggested im also going to use a client side check first to reduce the load on the server
:)
"Steven Burn" <nobody@PVT_it-mate.co.uk> wrote in message news:#s**************@TK2MSFTNGP11.phx.gbl... 'Make sure none of the boxes are empty (zero length) If len(firstname) = 0 or len(surname) = 0 or len(address1) = 0 or len(town) = 0 or len(county) = 0 or len(country) = 0 or len(postcode) = 0 or len(phone) = 0 or len(email11) = 0 or len(email2) = 0 or len(password1)
= 0 or len(password2) = 0 Then
Using Len and "Or" instead of "And" is a much better way of doing it. There's probably also a "cleaner" way of doing it..... I just can't
think of one at the moment.
-- Regards
Steven Burn Ur I.T. Mate Group www.it-mate.co.uk
Keeping it FREE!
Disclaimer: I know I'm probably wrong, I just like taking part ;o)
Gav <ga*****@ntlworld.com> wrote in message news:8l******************@newsfep2-win.server.ntli.net... Hi, At the moment i am checking that all the fields have been filled out,
at the moment i am using the following...
if firstname = "" and surname = "" and address1 = "" and town = "" and county = "" and country = "" and postcode = "" and phone = "" and email11 = "" and email2 = "" and password1 = "" and password2 = "" then
is there a better more efficient way of doing this??
cheers, gav
"MDW" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl... As much as I respect Ray, his solution would only work if ALL the entries were blank. If even one of those had text, then his test could produce a false positive.
That was how he had his original code setup. I thought about questioning it
but just decided against it. :]
Ray at work
"MDW" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl... As much as I respect Ray, his solution would only work if ALL the entries were blank. If even one of those had text, then his test could produce a false positive.
In addition, string concatenation is probably a more expensive operation
than checking the length of each string individually. Sorry Ray, but with
all due respect, I think you fell asleep at the wheel on this one. :)
Regards,
Peter Foti
I have yet to wake up this week. :]
Ray at work
"Peter Foti" <pe****@systolicNOSPAMnetworks.com> wrote in message
news:vv************@corp.supernews.com... "MDW" <an*******@discussions.microsoft.com> wrote in message news:01****************************@phx.gbl... As much as I respect Ray, his solution would only work if ALL the entries were blank. If even one of those had text, then his test could produce a false positive.
In addition, string concatenation is probably a more expensive operation than checking the length of each string individually. Sorry Ray, but with all due respect, I think you fell asleep at the wheel on this one. :)
Regards, Peter Foti
Detecting Null?
Null is defined as no valid data
If a form field named, say, firstname, is left empty when submitting the
form, then request.form.item("firstname") should return the contents of that
form's field, i.e. a zero-length string, which is valid data, it is not?
"Gav" <ga*****@ntlworld.com> wrote in message
news:8l******************@newsfep2-win.server.ntli.net... Hi, At the moment i am checking that all the fields have been filled out, at
the moment i am using the following...
if firstname = "" and surname = "" and address1 = "" and town = "" and county = "" and country = "" and postcode = "" and phone = "" and email11
= "" and email2 = "" and password1 = "" and password2 = "" then
is there a better more efficient way of doing this??
cheers, gav
Good point!
Ray, you're fired! -----Original Message----- "MDW" <an*******@discussions.microsoft.com> wrote in
messagenews:01****************************@phx.gbl... As much as I respect Ray, his solution would only work
if ALL the entries were blank. If even one of those had
text, then his test could produce a false positive. In addition, string concatenation is probably a more
expensive operationthan checking the length of each string individually.
Sorry Ray, but withall due respect, I think you fell asleep at the wheel on
this one. :) Regards, Peter Foti
.
On Tue, 30 Dec 2003 17:10:50 -0000, "Gav" <ga*****@ntlworld.com>
wrote: Hi, At the moment i am checking that all the fields have been filled out, at the moment i am using the following...
if firstname = "" and surname = "" and address1 = "" and town = "" and county = "" and country = "" and postcode = "" and phone = "" and email11 = "" and email2 = "" and password1 = "" and password2 = "" then
is there a better more efficient way of doing this??
Client side verification would be more appropriate for this I would
think. Besides, I'd just hit a space bar on all the fields so your
code would accept it... :)
Jeff
Hi!
I use the '+' operator instead of '&' as it results in a null if any single
argument is null, so you can do this:
IF ISNULL(strArg1 + strArg2 + strArg3 + ... + strArgN) THEN CALL
WreakHavoc
And your code only makes sure that all entries are not blank -- If anything
at all is filled in, it skips then THEN clause...
"Gav" <ga*****@ntlworld.com> wrote in message
news:8l******************@newsfep2-win.server.ntli.net... Hi, At the moment i am checking that all the fields have been filled out, at
the moment i am using the following...
if firstname = "" and surname = "" and address1 = "" and town = "" and county = "" and country = "" and postcode = "" and phone = "" and email11
= "" and email2 = "" and password1 = "" and password2 = "" then
is there a better more efficient way of doing this??
cheers, gav
Gav,
Hi again -- another post in this thread has relevant info as well -- Null
and Empty String ("") are not the same, and my previous post (about using
'+') will not work -- sorry! I did some quick testing to refresh my memory
and blank fields do not return Null...
So while my original post is relevant to Visual Basic, it won't help much
with ASP stuff. One approach I've used is to preface my text field names
with "req" for "required," soI'll have text fields named "reqtxtFName,"
"reqtxtLName" etc. then I cycle through all text fields with a "req" prefix
like so:
dim CtlName, bOK
bOK = True
For each CtlName in Request.Form
if left(CtlName, 3) = "req" then bOK = bOK AND Request.Form(CtlName)<>""
Next
If bOK Then 'Everthing was filled in...
This is handy for forms with a lot of fields...
Hope that helped...
Kurt
"Gav" <ga*****@ntlworld.com> wrote in message
news:8l******************@newsfep2-win.server.ntli.net... Hi, At the moment i am checking that all the fields have been filled out, at
the moment i am using the following...
if firstname = "" and surname = "" and address1 = "" and town = "" and county = "" and country = "" and postcode = "" and phone = "" and email11
= "" and email2 = "" and password1 = "" and password2 = "" then
is there a better more efficient way of doing this??
cheers, gav
MDW wrote: If your client side validation is tight enough, you really shouldn't need to do much by way of server-side validation. The only thing I use ASP for is functions that JavaScript doesn't provide, such as Replace.
Unfortunately it is _impossible_ to write a secure application without
doing server-side validation. A user can _always_ spoof input fields
because the user has complete control of the client side of the
interaction. For example, input may come from not a browser but from a
Perl program that mimics a browser. Such a program can be impossible to
detect.
If you're worried about people disabling scripting, one solution I've come up with is this:
<script language="JavaScript">
document.write("<input type=\"submit\" value=\"Submit\">);
</script>
<noscript> In order to submit this form, your browser must have script enabled. </noscript>
How to spoof the above:
save the HTML page, open it in NotePad, edit out the
<noscript>...</noscript> block, add the <input> fields, save the page
again, load it into the browser and submit the form.
Good Luck,
Michael D. Kersey
Nobody mentioned it, so I thought I would....You may want to throw a trim in
there to make sure that your fields aren't all spaces.
firstname = trim(Request.Form("firstname"))
"Gav" <ga*****@ntlworld.com> wrote in message
news:qL******************@newsfep2-win.server.ntli.net... Hi, Thanks for all the replies!!! much apreaciated.
I've gone with stevens method, seems to be the tidyest.
As suggested im also going to use a client side check first to reduce the load on the server
:)
"Steven Burn" <nobody@PVT_it-mate.co.uk> wrote in message news:#s**************@TK2MSFTNGP11.phx.gbl... 'Make sure none of the boxes are empty (zero length) If len(firstname) = 0 or len(surname) = 0 or len(address1) = 0 or len(town) = 0 or len(county) = 0 or len(country) = 0 or len(postcode) = 0 or len(phone) = 0 or len(email11) = 0 or len(email2) = 0 or len(password1)
= 0 or len(password2) = 0 Then
Using Len and "Or" instead of "And" is a much better way of doing it. There's probably also a "cleaner" way of doing it..... I just can't
think of one at the moment.
-- Regards
Steven Burn Ur I.T. Mate Group www.it-mate.co.uk
Keeping it FREE!
Disclaimer: I know I'm probably wrong, I just like taking part ;o)
Gav <ga*****@ntlworld.com> wrote in message news:8l******************@newsfep2-win.server.ntli.net... Hi, At the moment i am checking that all the fields have been filled out,
at the moment i am using the following...
if firstname = "" and surname = "" and address1 = "" and town = "" and county = "" and country = "" and postcode = "" and phone = "" and email11 = "" and email2 = "" and password1 = "" and password2 = "" then
is there a better more efficient way of doing this??
cheers, gav
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: bissatch |
last post by:
Hi,
Is it possible to write a script that, when provided with a database,
it will return all the tables names?
I will go onto try and put together a script that will not only output
the table...
|
by: Hal Vaughan |
last post by:
I am working on an install program, for another program that will need a
list of printers on a system. Originally I found the printers by doing
this:
public PrintNames() {
String tName = "";...
|
by: dschmidt |
last post by:
Does anybody know how to detect a NULL in a geometric box type?
When I execute the following sql statement (coords is a box type)
autotest=# select coords from dlg_control limit 1
autotest-# \g...
|
by: Rob |
last post by:
int *p;
p = malloc(1);
free(p);
/* */
In the above code, how do I detect that variable p points to nothing?
|
by: Randy |
last post by:
Hello,
How would one go about detecting which row/column was clicked in a datagrid.
I'm sure it can be done but I can't figure it out.
Thanks
|
by: Aarti |
last post by:
I have written a windows service that needs to perform certain functions only if a User is logged in. The problem I am running into is that I get an error if the computer is in the process of being...
|
by: D. Shane Fowlkes |
last post by:
I'm using SQL Server 2000 and on my page, I'm simply creating a
SQLDataReader and filling in Labels with the retrieved (single) record.
However, how can I prevent from getting errors when a field...
|
by: corepaul |
last post by:
I am using Acess 2000 and Windows 2000.
I have a form with a text box txLName. tStrGlobal As String is dimensioned
globally. The first time I enter the text box, the Enter event with the code
...
|
by: RobG |
last post by:
When using createEvent, an eventType parameter must be provided as an
argument. This can be one of those specified in DOM 2 or 3 Events, or
it might be a proprietary eventType.
My problem is...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |