用于日期验证的焦点文本框. [英] On focus textbox for date validation.

查看:66
本文介绍了用于日期验证的焦点文本框.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在这里,我将验证此格式yyyy/MM/dd usinf rangevalidator的正常工作,但我的任务是,如果用户输入错误的日期,则光标不能移到下一个字段,直到用户输入正确的日期,光标必须是相同的字段.你能告诉我我该怎么做吗.

告诉我任何一种程序,无论是其asp.net验证程序还是JavaScript,但我都需要使用它.

Hi all,

Here i m validate this format yyyy/MM/dd usinf rangevalidator its working fine but my task is if user enter wrong date the cursor must not go next field the cursor must be same field untill user enter proper date. can u tell me how can i do it.

tell me any kind of program either its asp.net validator or javascript but i need to work it.

推荐答案

在客户端(Javascript)中保留一个临时变量.在其中设置焦点对准的最后一个controlID.

现在,每当验证失败发生时,请使用此temp变量.如果验证失败,请将bool标志设置为true.

现在,在每个控件上定义onfocus.在其中,检查bool标志是否为true,如果是,则使用temp变量,并获取具有焦点的最后一个控件.放回去完成.

尝试!
Keep a temporary variable in client side (Javascript). Set the last controlID in it that was in focus.

Now, use this temp variable whenever the validation failure occurs. In case of validation failure, set a bool flag to true.

Now, define onfocus on each control. In it, check if bool flag is true, if so, use the temp variable and get the last control that had focus. set it back. Done.

Try!


使用正则表达式验证器
并使用它
ValidationExpression =(0 [1-9] | [12] [0-9] | 3 [01])[-/.](0[1-9]|1[012])[-/.](19 | 20)\ d \ d
use Regular Expression Validator
and use it
ValidationExpression="(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d


你好,

尝试将SetFocusOnError属性设置为true.如果那不起作用,请查看这篇文章.

http://weblogs.asp.net/dfindley/archive/2007/06/29/a-quick-fix-for-the-validator-setfocusonerror-bug.aspx
hello,

Try set the SetFocusOnError attribute to true. If that doesn''t work, check out this article.

http://weblogs.asp.net/dfindley/archive/2007/06/29/a-quick-fix-for-the-validator-setfocusonerror-bug.aspx


这篇关于用于日期验证的焦点文本框.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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