the required in the script do not working
$("#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
I make some radio field in my osclass theme on the item post!
<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>
I hide this on some categories (the required in the script do not work!!) Why??
<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>
What i need now it to make this radio fields required when show and not required wen hide! When show and required i need a error message Posted By: This field is required!
Hope someone can help me!