如何在更新字段后设置文本字段的焦点 [英] How To set the focus of a text field after updating the field

查看:71
本文介绍了如何在更新字段后设置文本字段的焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的项目我们有一个应该验证的日期字段,比如

出发日期不应该小于到达日期。

i已编写代码并且它正在工作很好,但问题是当我点击tabout时光标应该在同一个字段中,直到出发日期改变,它不应该去任何其他字段。

可以任何一个请建议我任何解决这个问题。

our project we have a date field which should be validate, Like
departure date should not be less than arrival date.
i have written the code and it is working fine, but the problem is when i click on tabout the cursor should be in the same field,until the departure date changes,it should not go to any other field.
could any one please suggest me any solution to this problem.

展开 | 选择 | Wrap | 行号

推荐答案

在第4行和第5行之间添加:
Between Lines 4 and 5 add:
展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号


您需要检查两个日期。您假设到货日期是正确的,并且输入出发日期时出错。反过来可能是相反的。


这段代码检查两个日期并为我工作。光标保留在文本框中

You need to check both dates. You are making the assumption that the Arrival Date is correct, and that there has been an error in entering the departure date. It could be the other way round.

This bit of code checks both dates and works for me. The cursor remains in the textbox

展开 | 选择 | Wrap | 行号


另外,不要包含原来的第4行。这是一种说将更改保存到此记录的方式。我怀疑那不是你所追求的。


看看Phil如何发布他的回复,并注意到他已经包含了所有相关信息 - 很多你错过了你的帖子。


从那里你可以看到无需调用 .Undo 。设置取消=真确保不接受他输入的值。是否可以使用 .Undo 将其恢复到原来的状态。由


NB。从技术上讲,你至少应该比较< =&的日期。 > =。只是< &安培; >不会测试你需要的东西。
Also, don''t include your original line #4. That is a way of saying "Save the changes to this record". I suspect that''s not what you were after.

Look at how Phil has posted his response and notice he''s included all the relevant information - much that you missed out of your post.

From that you can see that the call to .Undo is not necessary. Setting Cancel = True is what ensures that he entered value is not accepted. Whether you revert it to what it was beforehand with .Undo is up to you.

NB. Technically you should at least compare the dates for <= & >=. Just < & > does not test for what you need.


这篇关于如何在更新字段后设置文本字段的焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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