MVC3 上的文本框更改更新字段或启用“保存”按钮
我有一个 C#.Net MVCV3 Web 应用程序。有一个要求,当用户更改文本框中的文本并跳出文本框时,应用程序需要更新或修改页面标题,通过附加“*”来指示页面需要正在保存.....或者...启用“保存”按钮以指示需要保存页面。我不知道如何在客户端代码中执行此操作而不提交表单。有什么想法吗?
编辑以反映 3nigma 的评论摘要。需要将 keyup 和 Change 函数添加到 Window.Load 事件或 document.ready 事件中:
$(window).load(function () {
$("#Description").keyup(function (e) {
$("input[type='submit']").removeAttr("disabled");
document.title = document.title + "*";
});
});
或者
$(document).ready(function () {
$("#Description").keyup(function (e) {
$("input[type='submit']").removeAttr("disabled");
document.title = document.title + "*";
});
});
I have a C#.Net MVCV3 web app. There is a requirement that, when a user changes the text in a text box and tabs out of the text box, the app needs to update either modify the title of the page by appending a "*" to indicate the page is in need of saving.....OR...enable the Save button to indicate the page needs to be Saved. I don't know how to do this in the client code without submitting the form. Any ideas?
Editting to reflect summary of comments with 3nigma. The keyup and change functions needed to be added to either the Window.Load event or the document.ready event:
$(window).load(function () {
$("#Description").keyup(function (e) {
$("input[type='submit']").removeAttr("disabled");
document.title = document.title + "*";
});
});
OR
$(document).ready(function () {
$("#Description").keyup(function (e) {
$("input[type='submit']").removeAttr("disabled");
document.title = document.title + "*";
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用jquery,在文档准备好时禁用提交按钮,
将更改事件绑定到用户可以更改的字段,例如
textbox
或附加一个
*
,例如you can use jquery for that, on document ready disable the submit button
bind a change event to the fields that the user can change like
textbox
or append a
*
like您可以使用以下命令更改页面的标题。
将类似以下内容改编到任何更改功能中。
You can change the title of the page using the following.
Adapt something like the following into any change functions.