gpt4 book ai didi

jquery - 在填充主字段之前禁用字段

转载 作者:可可西里 更新时间:2023-11-01 13:00:09 25 4
gpt4 key购买 nike

因此,我正在创建此表单。顶部有 3 个主要字段。忽略其他人。组织名称、部门和地址。用户必须在部门和地址的组织字段中输入一些数据才能使用。

Here is the form这是我做的模型。如果用户没有在组织名称中输入任何信息,这就是它应该看起来的样子。

image 2

      <div class="control-group required">
<label class="control-label">Organisation Name <em>*</em></label>
<div class="controls">
<div class="input-append input-prepend">
<input type="text" class="input-xxlarge" id="Organisation-Name">
<button type="button" class="btn" href=""> Find</button>

</div>

</div>
</div>

<div class="control-group">
<label class="control-label">Department</label>
<div class="controls">
<div class="input-append input-prepend">

<input type="text" class="input-xxlarge" id="Department">
<button type="button" class="btn" href=""> Find</button>

</div>
<span class="help-inline"><i class="help" title="Enter the Department of this Opportunity.">Help</i></span>
</div>
</div>

<div class="control-group">
<label class="control-label">Address</label>
<div class="controls">
<div class="input-append input-prepend">

<input type="text" class="input-xxlarge" id="Address">
<button type="button" class="btn" href=""> Find</button>

</div>
<span class="help-inline"><i class="help" title="Enter the Address for this Opportunity.">Help</i></span>
</div>
</div>

我使用下面的建议设法使它看起来像这样。当我在组织字段中添加数据时,底部的 2 个字段需要恢复正常

Result

最佳答案

试试这个:https://jsfiddle.net/x0fwf6ro/

<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>

Name: <input id="name" type="text"> <br/>
Age: <input id="age" type="text" disabled> <br/>
Roll No: <input id="rollNo" type="text" disabled>

<script>

$(document).ready(function(){
$('#name').keyup(function(){
val = $('#name').val();
if(!!val){
$('#age').prop("disabled", false);
$('#rollNo').prop("disabled", false);
}
else{
$('#age').prop("disabled", true);
$('#rollNo').prop("disabled", true);
}
});
});

</script>

</body>

</html>

关于jquery - 在填充主字段之前禁用字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41018432/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com