将jQuery Readonly设置为定时解锁
Set jQuery Readonly to a timed unlock
我有一个表单,它有两个输入字段,一个完整的复选框和保存按钮。
勾选复选框并单击保存按钮后,将锁定输入框,使其无法进行任何后续编辑。
这工作正常。
我想在jQuery的只读上加一个时间,比如倒计时10秒。当它到达10秒结束时,它允许用户再次编辑表单。
如有任何帮助,我们将不胜感激。
HTML代码-
<fieldset>
<legend>General Information</legend>
<table class="full-width">
<tr>
<td><?php echo form::label('title', 'Summary of Problem') ?></td>
<td colspan="3">
<?php echo form::input('title', $test->title, array('class' => 'full-width', 'id' => 'title', 'style' => 'margin-left:2px')) ?>
</td>
</tr>
<tr>
<td><?php echo form::label('works_no','Works No.') ?></td>
<td><?php echo form::input('works_no', $test->works_no, array('id' => 'works_no')) ?></td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>Complete</legend>
<?php echo Form::checkbox('complete', NULL, FALSE, array('id' => 'complete')) ?>
<div class="columns">
<div class="colx2-left align-center">
<?php echo Form::button('save-test', 'Save Changes', array('id' => 'save-test', 'type' => 'button', 'value' => 'save-test')) ?>
</div>
jQuery代码-
$(function()
// Disable form input elements
$('#frm-test :input').attr('readonly', true);
$(document).on('mousedown keydown click', 'select, .datepicker, :radio', function(event) {
event.preventDefault();
});
// re-enable form elements with exclude class
$('#frm-test .exclude').removeAttr('readonly');
使用window.setTimeout()
javascript方法将ticker设置为10秒,如:
window.setTimeout(function() { // fuction to execute after timeout
$('#frm-test .exclude').removeAttr('readonly');
}, 10000); // timeout time in milliseconds
- Meteor-在一段时间内解锁模板(按日期)
- 解锁英特尔xdk中的屏幕
- jQuery blockUI 不会解锁
- 在网站上使用Javascript检测解锁屏幕
- 解锁流星注销并登录
- 如何锁定&解锁jqGrid
- 将jQuery Readonly设置为定时解锁
- jQuery通过点赞解锁内容
- 选中/未选中复选框时锁定/解锁文本输入
- 当鼠标向下时锁定滚动条,当鼠标向上时解锁
- 为教育形式创造可解锁的内容
- Segoe用户界面锁定解锁符号符号在AppBar
- 我怎么能把它发送到特定的链接时,一些滑动解锁
- 为什么元素的解锁会失败?
- 实现锁定&在编辑时解锁文档
- 在meteor中使用mongo aggregate来累计集合中的解锁/锁定
- 如何锁定/解锁鼠标滚动在PHP/html/Javascript
- 解锁/启用用户当前选择的相邻下拉菜单
- 当内容被Backbone.js替换时,如何解锁jquery ui检查按钮
- 为什么getCurrentPosition()在解锁googleChromeAndroid的gps访问后失败