2017-04-17 23 views
-1

を働いていない私は、アイテムポストに私のosclassテーマにいくつかの電波を作る必要なコードは、スクリプトに必要な

$("#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> 

私はこれをいくつかのカテゴリで非表示にしています(スクリプトで必要なものは動作しません!!)

<script type="text/javascript"> 
$('#catId').change(function(){ 
    if($('#catId').val() == "28" || $('#catId').val() == "29" || 
$('#catId').val() == "30" || $('#catId').val() == "31") 
    { 
     $("#postby").hide(); // change Posted By with ID you give to the div 
    $("#s_postby").attr('required', false); // put the id of the input field that you whant required 
    }else 
    { 
     $("#postby").show(); // change Posted By with ID you give to the div 
    $("#s_postby").attr('required', true); // put the id of the input field that you whant required 
    } 
}); 
</script> 

私が今必要とするのは、この無線フィールドを表示する際に必要なもので、必要でないものです。wen hide!ショーと必要なときに私はエラーメッセージが必要投稿者:このフィールドは必須です!

誰かが私を助けることを願っています!

+3

あなたの[受諾](https://meta.stackexchange.com/a/5235/)レコードは疑問です。 –

+0

'#s_postby'は'#s_postbyNUMBER'とは一致しません。 '$( 'input [name =" postby "])。それぞれが近いかもしれません。JSはあまりありませんが、PHPは私をここに連れてきました。 – chris85

+1

問題を解決するのに役立つ[回答を受け入れる](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)の習慣を身につける必要があります。あなたはポイントを獲得し、他の人はあなたを助けることを奨励されます。 –

答えて

1
+3

* "ああ、あなたが女子学生であることを誰も気にしていません" * - その言葉は答えにあってはならないと私はそのうぬぼれを編集しました。 。 –

+1

@ Fred-ii-しかし、私は正しいです – broodjetom

+0

それは自分の自己に保つべきコメントです;-) –

関連する問題