如果可见,则使文本框成为必填项(基于单选按钮选择是/否,文本框可见) [英] Make textbox mandatory if visible(textbox is visible based on radio button selection yes/no)

查看:114
本文介绍了如果可见,则使文本框成为必填项(基于单选按钮选择是/否,文本框可见)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有单选按钮列表,选择是/否,我需要隐藏/显示文本框。

如果选择是,则文本框可见,如果否则隐藏。

如果文本框可见,那么我需要使用Jquery强制使用。



我尝试过:



如果检查了radiobtn.selected

则必须使用textbox。

I have radio button list and on selection of Yes/No ,I need to hide/show textbox.
If yes is selected, then textbox is visible and If No then hidden.
If textbox is visible then I need to make it mandatory using Jquery.

What I have tried:

If radiobtn.selected checked
Then textbox is mandatory.

推荐答案

试试这个



try this

<html>
<head>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

    <script>
        function check() {
            var value =


('input [name = opt]:checked')。val();
if(value =='Yes')
('input[name=opt]:checked').val(); if (value == 'Yes')


('#txtbox')。show();
else
('#txtbox').show(); else


这篇关于如果可见,则使文本框成为必填项(基于单选按钮选择是/否,文本框可见)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆