[英]how to make a field requried when the checkbox is checked
hello i am new to jsp and javascript, and i would like to a make a field required when the checkbox is checked, 你好,我是jsp和javascript的新手,我想在选中此复选框时填写一个必填字段,
<tr>
<th class="clsTableHeaderLeft">InterCompany</th>
<td class="clsDisplayText">
<% if (!tHideField.equals("")){
out.println(tRecord.get(idxInterComFlag).toString());
}
%>
<input type="checkbox" class="clsInputText" <%=tHideField%> name="txtInterComFlag" onchange="chgStatus(txtStatus);" size="25" maxlength="20"
<%=tRecord.get(idxInterComFlag).toString().equals("Y")?" checked":""%>
/>
</td>
</tr>
<tr>
<th class="clsTableHeaderLeft">Entity Code</th>
<td class="clsDisplayText">
<% if (!tHideField.equals("")){
out.println(tRecord.get(idxInterComCode).toString());
}
%>
<input type="text" class="clsInputText" <%=tHideField%> name="txtInterComCode" size="25" maxlength="20" />
</td>
</tr>
also the checkbox value is 'on' when checked , how can I make it to Y or N? 如果选中复选框的值也为“ on”,如何将其设置为Y或N? thank you!
谢谢!
I had a same requirement, so i Choose to follow this flow: 我有相同的要求,所以我选择遵循以下流程:
Here is my sample Code: 这是我的示例代码:
function fxctco() { var newHTML="<input type='number' name='fctc' required/>"; document.getElementById("ctc").innerHTML = newHTML; }
<table><tr><TD ><input type="radio" name="fx"value="YES" onClick="fxctco()"> Yes <input type="radio" name="fx"value="NO" checked> No</TD></tr> <tr><TD id="ctc"> <INPUT TYPE="number" NAME="fctc" /></TD></tr> <tr> <TD align="center"><INPUT TYPE="submit" class="button" VALUE="submit"></TD> </tr> </table>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.