如果使用 jquery 在表单提交中选择单选按钮,我如何需要文本框?
如果选择了第二个单选按钮,如何要求第二个文本框在提交此表单时包含一些文本?
<form action="" method="post" id="search_form" name="search_form">
<div id="inquryValue-form-item" class="form-item">
<div class="form-radio display-inline">
<input type="radio" class="required" value="" checked="checked" id="inquryValue" name="search_value">
</div>
<div class="field-label-45-percent display-inline">
<label>
Inquiry ID
</label>
</div>
<div id="fepUserIDValueWrapper" class="form-radio display-inline">
<input type="radio" class="required" value="" id="fepUserIDValue" name="search_value">
</div>
<div class="field-label-45-percent display-inline">
<label id="fepUserIDValueLabel" for="fepUserIDValue">
FEPDirect User ID
</label>
</div>
<div id="inquiry_dateLabelWrapper" class="field-label-45-percent display-inline">
<label id="inquiry_dateLabel" for="inquiry_date">
Inquiry Date
</label>
</div>
</div>
<div id="fepUserIDValue-form-item" class="form-item">
<div id="Search_valueWrapper" class="form-textfield">
<input type="text" class="required" value="" id="search_value" name="search_value">
</div>
<div id="Inquiry_dateWrapper" class="form-textfield">
<input type="text" name="inquiry_date" id="inquiry_date" class="date-picker hasDatepicker">
<div id="search_value_labelWrapper" class="field-label">
<div class="field-description">
<span title="This field is required if entering a User ID" class="required">*</span>
This field is required if entering an User ID
</div>
</div>
</div>
<input type="button" id="search_inquiry-submit" class="neutral" value="Search">
</div>
</form>
How do I require the second text box have some text in it on the submission of this form if the second radio button is selected?
<form action="" method="post" id="search_form" name="search_form">
<div id="inquryValue-form-item" class="form-item">
<div class="form-radio display-inline">
<input type="radio" class="required" value="" checked="checked" id="inquryValue" name="search_value">
</div>
<div class="field-label-45-percent display-inline">
<label>
Inquiry ID
</label>
</div>
<div id="fepUserIDValueWrapper" class="form-radio display-inline">
<input type="radio" class="required" value="" id="fepUserIDValue" name="search_value">
</div>
<div class="field-label-45-percent display-inline">
<label id="fepUserIDValueLabel" for="fepUserIDValue">
FEPDirect User ID
</label>
</div>
<div id="inquiry_dateLabelWrapper" class="field-label-45-percent display-inline">
<label id="inquiry_dateLabel" for="inquiry_date">
Inquiry Date
</label>
</div>
</div>
<div id="fepUserIDValue-form-item" class="form-item">
<div id="Search_valueWrapper" class="form-textfield">
<input type="text" class="required" value="" id="search_value" name="search_value">
</div>
<div id="Inquiry_dateWrapper" class="form-textfield">
<input type="text" name="inquiry_date" id="inquiry_date" class="date-picker hasDatepicker">
<div id="search_value_labelWrapper" class="field-label">
<div class="field-description">
<span title="This field is required if entering a User ID" class="required">*</span>
This field is required if entering an User ID
</div>
</div>
</div>
<input type="button" id="search_inquiry-submit" class="neutral" value="Search">
</div>
</form>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
Try this:
看这个问题: jQuery.Validate 条件验证 RadioButton 和 DropDownList
Look at this question: jQuery.Validate Conditional Validation RadioButton and DropDownList