我只想显示24个以下的数字! [英] I want display below 24 numbers only!

查看:77
本文介绍了我只想显示24个以下的数字!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我给你讲一个例子!仅接受数字的文本框(不显示字符)!在下面的代码中可用!

Ajax的代码(Java脚本):

Hi,

I will tell u one example! Text box which accepts only numbers (characters will not be displayed)! In below code is available!

Code for Ajax(java script) :

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>



我只下载了"AjaxControlToolkit.dll",并刚刚添加了该工具包的参考资料!

还有



i just download "AjaxControlToolkit.dll" and just added reference for that toolkit !

And

<cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" FilterMode="ValidChars" runat="server"
                TargetControlID="txtSun1N" ValidChars="1234567890.">
               </cc1:FilteredTextBoxExtender>



这是文本框仅接受数字的方式!如果我们输入任何字符,则文本框将不会显示在该文本框中.
像这样,如果我们输入任何其他数字(24以上)意味着无法显示25,26,3234534 ..,当我们尝试输入任何其他数字时,该数字将无法显示..我需要那个!

谁能帮我!! .



this is the way to text box accepting numbers only! If we enter any characters that text box will not be displayed in that text box.. Just try it''s working !!

Like that if we enter any other number(above 24) means 25,26,3234534.. can''t be display, When we tried to enter any other number that number can''t be displayed..I need that!!

Can any one help me!! .

推荐答案

y为此使用ajax

只需使用asp正则表达式验证器只需1到24.



只需使用asp范围验证器即可获取具有最小值和最大值的数字.



如果要实现遮罩效果,请使用"ajaxToolkit:MaskedEditValidator",而不是过滤文本框扩展器.您可以将掩码设置为"99",范围从1到24.
y using ajax for this

just use asp regular expression validator to take only 1 to 24.

OR

simply use asp range validator to take numbers with min and max value.

OR

use ''ajaxToolkit:MaskedEditValidator'' rather then filter text box extender if you want to achieve the mask effect. you can set the mask as ''99'' and range from 1 to 24.


有两种方法可以实现.

让我从应该避免的错误方式入手.不要尝试使用与过滤输入相同的想法.我可以轻松地创建一些JavaScript来过滤输入内容,只允许1到24或0到24,无论您想要什么,但这都会使用户感到困惑.假设用户输入23并想将其更改为21.用户可以删除"3"并输入"1".但是她/他可能想先添加"1",然后再获得"231",然后再删除"3".您进行过滤将阻止它离开用户,而又对该操作没有任何合理的反馈.不要尝试引入过于复杂的过滤器!

相反,如果您真的想保留文本输入,则可以使用对输入的字符进行过滤的组合,使用 validation 可以很好地实现输入.不要过早进行验证;仅在将要使用用户输入的数据时才执行此操作.为用户提供有关有效输入的明确反馈,例如"{0}的值必须为{1}到{2}",类似这样.

我会使用更简单的方法.如果您只希望输入24个左右的有效值,那么我会简单地使用一个组合框,并预先输入所有值.用户将仅选择其中之一.参见 http://www.asp.net/web-forms/tutorials/ajax-control-toolkit/combobox/how-do-i-use-the-combobox-control-cs [
There are two ways to achieve this.

Let me start with the wrong way you should avoid. Don''t try to use the same idea as filtering the input. I could easily create some JavaScript to filter input the way allowing only 1 to 24 or 0 to 24, whatever you want, but it will highly confuse the user. Imagine the user enters 23 and wants to change it to 21. The user can delete ''3'' and enter ''1''. But she/he might want to add ''1'' first to get ''231'' to delete ''3'' later. You filter will prevent it leaving the user without any reasonable feedback on what to do. Don''t try to introduce too complex filtering!

Instead, if you really want to stay with text input, you can use combination of filtering of characters on input, which you already achieved quite well, with validation. Don''t perform validation too early; do it only when the data input by the user is about to be used. Give a user clear feedback on the valid input, such as "The value of {0} must be {1} to {2}", something like that.

I would use much simpler approach though. If you expect only 24 valid values or so, I would simply uses a combo box with all values pre-entered. The user will only select one of them. See http://www.asp.net/web-forms/tutorials/ajax-control-toolkit/combobox/how-do-i-use-the-combobox-control-cs[^].

—SA


我认为同时使用MaskedEditExtenderMaskedEditValidator 可以解决您的问题.

在这里看看:
http://www.asp.net/ajaxlibrary/HOW%20TO%20Use% 20the%20MaskedEdit%20Control.ashx [ ^ ]

在这里:
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/MaskedEdit/MaskedEdit.aspx [ ^ ]

希望对您有所帮助.
I think using MaskedEditExtender and MaskedEditValidator together will solve your problem.

Have a look at here:
http://www.asp.net/ajaxlibrary/HOW%20TO%20Use%20the%20MaskedEdit%20Control.ashx[^]

and here :
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/MaskedEdit/MaskedEdit.aspx[^]

Hope it helps.


这篇关于我只想显示24个以下的数字!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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