文本框值大于零?客户端检查? [英] textbox value greater than zero? Client-side check?

查看:59
本文介绍了文本框值大于零?客户端检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定如何确切地问这个,但是期待它是一个Javascript

解决方案。但是,我会问这个问题,也许有人可以指出一些现有代码可以做我需要的东西。


我有一个Asp在2.0框架中的.Net应用程序。我有一个页面是

一种店面类型的页面,它有一个产品,一个数量和一个用于添加到购物车的

按钮。一个用于添加到心愿单。

如果数量不大,我想禁用这两个按钮

比零。

有人可以帮忙吗?

I''m not sure how to exactly ask this, but expect that it''s a Javascript
solution. However, I''ll ask the question and maybe someone can point
me to some existing code that will do what I need.

I have an Asp.Net app that''s in 2.0 framework. I have a page that is
sort of a storefront sort of page that has a product, a quantity and a
button for "Add To Cart" and one for "Add To Wishlist".
I''d like to disable those two buttons if the quantity is not greater
than zero.
Can someone help?

推荐答案




HockeyFan写道:
Hi,

HockeyFan wrote:

我不知道如何确切地问这个问题,但期望它是一个Javascript

解决方案。但是,我会问这个问题,也许有人可以指出一些现有代码可以做我需要的东西。


我有一个Asp在2.0框架中的.Net应用程序。我有一个页面是

一种店面类型的页面,它有一个产品,一个数量和一个用于添加到购物车的

按钮。一个用于添加到心愿单。

如果数量不大,我想要禁用这两个按钮

比零。
I''m not sure how to exactly ask this, but expect that it''s a Javascript
solution. However, I''ll ask the question and maybe someone can point
me to some existing code that will do what I need.

I have an Asp.Net app that''s in 2.0 framework. I have a page that is
sort of a storefront sort of page that has a product, a quantity and a
button for "Add To Cart" and one for "Add To Wishlist".
I''d like to disable those two buttons if the quantity is not greater
than zero.



对这样的事情使用比较验证器 - 这些将验证客户端

上的数据。将按钮的CausesValidation属性设置为True,为每个文本框添加一个

比较验证器,将它们链接到另一个文本框。如果您需要

几个不同的验证组,请使用ValidationGroup属性。如果

你想要显示一条消息(而不是或者另外

来显示控件旁边的错误消息),请使用

ValidationSummary-control。


干杯,

奥拉夫

-

我的.02: www.Resources.IntuiDev.com


在没有看到你的代码的情况下脱离我的头顶:我想你可以

默认按钮被禁用并激活TextChanged。在数量文本框中输入值或

SelectedIndexChanged如果是下拉列表,则为event。在这些

事件中,您可以启用按钮。您可能需要在事件中加入

代码来检查您的数量是否大于0并且

相应地启用/禁用(用户可以从购物车中删除商品)以及

添加?)。


HockeyFan写道:
Off the top of my head without seeing your code: I suppose you could
default the buttons to be disabled and fire the "TextChanged" event
when a value is entered in a quantity textbox or the
"SelectedIndexChanged" event if it is a drop down list. In these
events, you can then enable the buttons. You will probably need to put
code in the events to check if your qty is greater than 0 or not and
enable/disable accordingly (the user may remove items from cart as well
as add?).

HockeyFan wrote:

我是不确定如何确切地问这个,但期望它是一个Javascript

解决方案。但是,我会问这个问题,也许有人可以指出一些现有代码可以做我需要的东西。


我有一个Asp在2.0框架中的.Net应用程序。我有一个页面是

一种店面类型的页面,它有一个产品,一个数量和一个用于添加到购物车的

按钮。一个用于添加到心愿单。

如果数量不大,我想禁用这两个按钮

比零。

有人可以帮忙吗?
I''m not sure how to exactly ask this, but expect that it''s a Javascript
solution. However, I''ll ask the question and maybe someone can point
me to some existing code that will do what I need.

I have an Asp.Net app that''s in 2.0 framework. I have a page that is
sort of a storefront sort of page that has a product, a quantity and a
button for "Add To Cart" and one for "Add To Wishlist".
I''d like to disable those two buttons if the quantity is not greater
than zero.
Can someone help?




HockeyFan写道:

HockeyFan wrote:

我是不确定如何确切地问这个,但期望它是一个Javascript

解决方案。但是,我会问这个问题,也许有人可以指出一些现有代码可以做我需要的东西。


我有一个Asp在2.0框架中的.Net应用程序。我有一个页面是

一种店面类型的页面,它有一个产品,一个数量和一个用于添加到购物车的

按钮。一个用于添加到心愿单。

如果数量不大,我想禁用这两个按钮

比零。

有人可以帮忙吗?
I''m not sure how to exactly ask this, but expect that it''s a Javascript
solution. However, I''ll ask the question and maybe someone can point
me to some existing code that will do what I need.

I have an Asp.Net app that''s in 2.0 framework. I have a page that is
sort of a storefront sort of page that has a product, a quantity and a
button for "Add To Cart" and one for "Add To Wishlist".
I''d like to disable those two buttons if the quantity is not greater
than zero.
Can someone help?



奥拉夫的建议看起来不错。验证器非常适合

这样的情况。

Olaf''s advice looks good. Validators are ideal for situations like
this.


这篇关于文本框值大于零?客户端检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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