检测为空 [英] detecting null

查看:65
本文介绍了检测为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



目前我正在检查所有字段是否已填写完毕,在

时刻我正在使用以下内容...


如果firstname =""和姓氏=""和address1 =""和镇=""和

county =""和country =""和邮政编码=""和电话=""和email11 =

""和email2 =""和password1 =""和password2 =""然后


有更好的方法吗?


欢呼,

gav

解决方案

你可以将它们连接起来:


sStringSum = firstname&姓氏和地址1&小镇&县& country&

邮政编码&电话&电子邮件11& email2&密码1&密码2


如果Len(Trim(sStringSum))= 0那么

Response.Write你没有填写任何东西。

Response.End

结束如果


Ray在工作


" Gav" < GA ***** @ ntlworld.com>在消息中写道

news:8l ****************** @ newsfep2-win.server.ntli.net ...


目前我正在检查所有字段是否已填写完毕,当我使用以下内容时
...

如果firstname = ""和姓氏=""和address1 =""和镇=""和
county =""和country =""和邮政编码=""和电话=""和电子邮件11
=""和email2 =""和password1 =""和password2 =""那么

是否有更好的更有效的方法呢?

欢呼,
gav



不幸的是,我就是这样做的。


另外,你是否事先在客户端检查过这个问题?使用Javascript进行一些表单验证可能是个好主意,首先,所以你自己保存

去服务器。

" GAV株系" < GA ***** @ ntlworld.com>在消息中写道

news:8l ****************** @ newsfep2-win.server.ntli.net ...


目前我正在检查所有字段是否已填写完毕,当我使用以下内容时
...

如果firstname = ""和姓氏=""和address1 =""和镇=""和
county =""和country =""和邮政编码=""和电话=""和电子邮件11
=""和email2 =""和password1 =""和password2 =""那么

是否有更好的更有效的方法呢?

欢呼,
gav



这只会告诉您所有字段都是空的。 (如果名字是

空白*和*姓氏是空白*和* ...)

我通常使用客户端验证,我有在JavaScript中检查每个表单

字段,如果任何字段为空,表单不会提交

提交并要求他们填写数据。这样,服务器

不需要做任何工作检查,并立即告诉用户

而不是浪费时间提交数据并等待服务器到

回应。您还可以更轻松地跟踪他们已经正确填写的数据,因为如果它是$
$,您不必重新填充表单。 b $ b从未提交过。


当然你也在服务器上查看,因为有些人因某些原因不允许使用

JavaScript。但是你可以通过在客户端停止99%的潜在错误来节省大量的时间和服务器来处理。


Gav < GA ***** @ ntlworld.com>在消息中写道

news:8l ****************** @ newsfep2-win.server.ntli.net ...


目前我正在检查所有字段是否已填写完毕,当我使用以下内容时
...

如果firstname = ""和姓氏=""和address1 =""和镇=""和
county =""和country =""和邮政编码=""和电话=""和电子邮件11
=""和email2 =""和password1 =""和password2 =""那么

是否有更好的更有效的方法呢?

欢呼,
gav



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

解决方案

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



这篇关于检测为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆