EasyUI Forum

General Category => General Discussion => Topic started by: anugrast on August 13, 2016, 08:17:21 PM



Title: Switchbutton and Datebox
Post by: anugrast on August 13, 2016, 08:17:21 PM
How to set datebox readonly and required base on switchbutton...
I mean when I change switchbutton ON, datebox set to readonly=false and required=true. If I change switchbutton OFF, datebox set to readonly=true and required=false.

This is my code:

Code:
	$('#id_bayar_udom').switchbutton({
onChange: function(value){
if(value==false) {
                                $('#id_awal_tgl_perpanjang_udom').datebox({readonly:true,required:false});
} else {
                                $('#id_awal_tgl_perpanjang_udom').datebox({readonly:false,required:true});
}
}
});



Title: Re: Switchbutton and Datebox
Post by: jarry on August 14, 2016, 07:04:21 AM
Please try this code:
Code:
$('#id_bayar_udom').switchbutton({
onChange: function(value){
var db = $('#id_awal_tgl_perpanjang_udom');
var conf = {value: db.datebox('getValue')};
if (value){
$.extend(conf, {
readonly: false,
required: true
});
} else {
$.extend(conf, {
readonly: true,
required: false
});
}
db.datebox(conf);
}
});


Title: Re: Switchbutton and Datebox
Post by: anugrast on August 14, 2016, 06:01:47 PM
Problem solved... Thanks for your help Jarry...

You are the best.... :) :) :) :) :)