Radio and checkbox check, uncheck condition

/////// for radio /////////////

$(‘.shipping_method’).on(‘ifChecked’, function(){

if($(this).val() == 1){
$(‘#shipping_method_div’).show();
}else{
$(‘#shipping_method_div’).hide();
$(‘#tracking_reference’).val(”);
$(‘#courier’).val(”);
}
});

/////// for checkbox ///////

$(“#communication_other”).on(‘ifChecked’, function(){
$(‘#communication_other_text_div’).show();
});
$(“#communication_other”).on(‘ifUnchecked’, function(){
$(‘#communication_other_text_div’).hide();
$(‘#communication_other_text_div’).find(‘input:text’).val(”);
});

Start date from week entering fill the other field date

$(‘.section_week’).keyup(function() {
var section_id =$(this).attr(“alt”);
var date = $(‘#start_date_section’+section_id).datepicker(‘getDate’);
if(date !=”Invalid Date”){
var week = $(this).val();
var total = week*7;
Date.prototype.addDays = function(days) {
var date = new Date(this.valueOf());
date.setDate(date.getDate() + days);
return date;
}
var get_date = date.addDays(total);
var final_date = (((get_date.getDate() > 9) ? get_date.getDate() : (‘0’ + get_date.getDate())) + ‘-‘ + ((get_date.getMonth() > 8) ? (get_date.getMonth() + 1) : (‘0’ + (get_date.getMonth() + 1))) + ‘-‘ + get_date.getFullYear());
$(‘#complete_date_section’+section_id).val(final_date);
}else{
alert(“Please Select Start Date First”);
$(‘#no_of_week_section’+section_id).val(”);
}
});

Age Validation in JavaScipt

//age handling
var dob = $(“#date_of_birth”).val();
var arr = dob.split(‘-‘);

var day = arr[0];
var month = arr[1];
var year = arr[2];
var age = 18; //allowed age
var mydate = new Date();
mydate.setFullYear(year, month-1, day);
var currdate = new Date();
currdate.setFullYear(currdate.getFullYear() – age);

if ((currdate – mydate) < 0){
alert(“Your age should be greater than 18 years for registration “);
is_error = true;
return false;
}
//age handling