Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 脚本中所需的代码不起作用_Javascript_Php_Html - Fatal编程技术网

Javascript 脚本中所需的代码不起作用

Javascript 脚本中所需的代码不起作用,javascript,php,html,Javascript,Php,Html,脚本中所需的命令无效 $("#s_postby").attr('required', false); // put the id of the input field that you whant required $("#s_postby").attr('required', true); // put the id of the input field that you whant required 我做了一些广播领域在我的奥斯卡主题的项目后 <div id="postby"

脚本中所需的命令无效

$("#s_postby").attr('required', false); // put the id of the input field that you whant required
$("#s_postby").attr('required', true); // put the id of the input field that you whant required
我做了一些广播领域在我的奥斯卡主题的项目后

    <div id="postby" class="property-ads-100">
      <label>
        <span class="required_fields">*</span>
        <?php _e('Posted By', 'ctg_housing'); ?>
      </label>
      <div class="item-post-postby-checkbox columns-0">
        <input  type="radio" name="s_postby" value="owner" id="s_postby0" <?php if(isset($housing['s_postby']) && $housing['s_postby'] =='owner') { echo 'checked="checked"'; }; ?>>
        <label for="s_postby0">
          <?php _e('Owner', 'ctg_housing'); ?>
        </label>
      </div>
      <div class="item-post-postby-checkbox columns-0">
        <input type="radio" name="s_postby" value="agent" id="s_postby1" <?php if(isset($housing['s_postby']) && $housing['s_postby'] =='agent') { echo 'checked="checked"'; }; ?>>
        <label for="s_postby1">
          <?php _e('Agent', 'ctg_housing'); ?>
        </label>
      </div>
      <div class="item-post-postby-checkbox columns-0">
        <input type="radio" name="s_postby" value="broker" id="s_postby2" <?php if(isset($housing['s_postby']) && $housing['s_postby'] =='broker') { echo 'checked="checked"'; }; ?>>
        <label for="s_postby2">
          <?php _e('Broker', 'ctg_housing'); ?>
        </label>
      </div>
      <div class="item-post-postby-checkbox columns-0">
        <input type="radio" name="s_postby" value="agency" id="s_postby3" <?php if(isset($housing['s_postby']) && $housing['s_postby'] =='agency') { echo 'checked="checked"'; }; ?>>
        <label for="s_postby3">
          <?php _e('Agency', 'ctg_housing'); ?>
        </label>
      </div>
    </div>

*
我在某些类别上隐藏了这一点(脚本中的必需项不起作用!!)为什么


$('#catId')。更改(函数(){
如果($('#catId').val()=“28”|$('#catId').val()=“29”| |
$('#catId').val()=“30”|$('#catId').val()=“31”)
{
$(“#postby”).hide();//使用您给div的ID更改postby
$(“#s_postby”).attr('required',false);//输入不需要的输入字段的id
}否则
{
$(“#postby”).show();//使用您给div的ID更改postby
$(“#s_postby”).attr('required',true);//输入不需要的输入字段的id
}
});
我现在需要的是它,使这个无线电领域需要时显示,而不是需要隐藏!当显示和需要时,我需要一条错误消息发布者:此字段是必需的

希望有人能帮助我

element.required = true;


你的记录有问题。我认为
#s#u postby
不会匹配
#s#u postbyNUMBER
<代码>$('input[name=“postby”])。每一个都可能更接近。。我不太喜欢JS,PHP把我带到了这里。你需要养成习惯,它可以帮助你解决问题。您将获得积分,并鼓励其他人帮助您。谢谢,我将尝试此方法,并让您知道您的记录是否有问题。我认为
#s#u postby
不会与
#s#u postbyNUMBER
匹配<代码>$('input[name=“postby”])。每一个都可能更接近。。我不太喜欢JS,PHP把我带到了这里。你需要养成习惯,它可以帮助你解决问题。你会得到分数,其他人会被鼓励帮助你。谢谢,我会尝试一下,让你知道如果工作“哦,没有人关心你是女生。”-答案中不应该提到这一点,我删掉了这一点,并在问题中。@Fred ii-但我是对的,这是一个最好保持自我的评论;-)“哦,没人在乎你是女生。”-答案中不应该提到这一点,我删掉了问题中的那一点。@Fred ii-但我是对的,这是一个最好对自己保密的评论;-)
element.required = true;