How to make calendar dates setSensitiveRange

Hi,

I need to setSensitiveRange in form. I loading the form field data from database. while load the dates should set for setSensitiveRange based on the dates getting loaded.

i am getting the date displayed in the form field through window.dhx4.ajax.post

after loading the data. i am unable to create sensitiverange for dates which is displayed.

kindly help me with sample codes. below is form details.

formData = [{type: “settings”,position:“label-left”},
{type: “block”, inputWidth:500,list:[
{type:“fieldset”, inputWidth:500, label:“CFT CALCULATION DETAILS”,list:[
{type:“input”, name:“cclcode”, label:“CH CODE”, labelWidth:“200”,inputWidth:“150”, readonly:true,required:true,validate:“NotEmpty,ValidAplhaNumeric”, readonly:true},
{type:“calendar”, name:“cfstdate”, id:“cfstdate”, label:“CFT CAL. START DATE”, labelWidth:“200”,inputWidth:“100”,required:true,dateFormat: “%d-%m-%Y”, serverDateFormat:“%Y-%m-%d”, calendarPosition:“right”,validate:“NotEmpty”},
{type:“calendar”, name:“cfeddate”, label:“CFT CAL. END DATE”, labelWidth:“200”,inputWidth:“100”,required:true,dateFormat: “%d-%m-%Y”, serverDateFormat:“%Y-%m-%d”, calendarPosition:“right”,validate:“NotEmpty”},
{type:“combo”, id:“cftype”,name:“cftype”, label:“TYPE”, options:[
{text: “SELECT”, value: “”},
{text: “LTL”, value: “LTL”},
{text: “FTL”, value: “FTL”},
{text: “DV”, value: “DV”},
],labelWidth:“200”,inputWidth:“100”,required:true,validate:“NotEmpty”},
{type:“combo”, id:“cftranstype”,name:“cftranstype”, label:“TRANSPORT MODE”,labelWidth:“200”,inputWidth:“100”,required:true,validate:“NotEmpty”},

			{type:"combo", id:"cfcontype",name:"cfcontype", label:"CFT CONVERSATION TYPE", options:[
			{text: "SELECT", value: ""},
			{text: "CMS", value: "CMS"},
			{text: "INCHS", value: "INCHS"}
			],labelWidth:"200",inputWidth:"150",required:true,validate:"NotEmpty"}, 	
			{type:"input",name:"cfbase",label:"CFT CONVERSATION VALUE",labelWidth:"200",inputWidth:"100",readonly:true,required:true,validate:function(v){return v.match(/^[0-9\s&-_]*$/gi)!=null;}},
			{type:"input",name:"cftkg",label:"CFT CONVERSATION KGS",value:"",labelWidth:"200",inputWidth:"120",required:true,validate:function(v){return v.match(/^[0-9\s&-_]*$/gi)!=null;}},
			{type: "input", name:"remarks",label: "REMARKS", value: "",labelWidth:"100",inputWidth:"300",validate:function(v){return v.match(/^[A-Z0-9\s&-_]*$/gi)!=null;}},
			{type:"button" , name:"1", label:"Button", value:"Submit"}
			]}
			]}
			];

Hi

please try the following:

var myForm = new dhtmlXForm([ {type: "calendar", name: "cfstdate", dateFormat: "%Y-%m-%d" ...}, {type: "calendar", name: "cfeddate", dateFormat: "%Y-%m-%d" ...} ]); myForm.load("data.xml", function(){ checkRange("cfstdate", myForm.getItemValue("cfstdate")); checkRange("cfeddate", myForm.getItemValue("cfeddate")); }); myForm.attachEvent("onChange", function(name, value){ if (name == "cfstdate" || name == "cfeddate") checkRange(name, value); }); function checkRange(name, value) { if (name == "cfeddate") { myForm.getCalendar("cfstdate").setSensitiveRange(null, value); } else { myForm.getCalendar("cfeddate").setSensitiveRange(value, null); } }

data.xml

<data> <cfstdate>2016-03-01</cfstdate> <cfeddate>2016-03-03</cfeddate> </data>

but note that user can enter date into form field manualy, so you probably need readonly:true attr or extracheck.

Hi,
I have loaded the form as per your instruction. But still dates setSensitiveRange are not working.

newContactForm.load("…/menu4/getClient.jsp?id="+ccllcode+"&etc="+new Date().getTime(), function(){
checkRange(“cfstdate”, newContactForm.getItemValue(“cfstdate”));
checkRange(“cfeddate”, newContactForm.getItemValue(“cfeddate”));
});

newContactForm.attachEvent(“onChange”, function(name,value){
if (name == “cfstdate” || name == “cfeddate”)
checkRange(name, value);
});

function checkRange(name, value) {
if (name == “cfeddate”)
{
newContactForm.getCalendar(“cfstdate”).setSensitiveRange(null, value);
}
else
{
newContactForm.getCalendar(“cfeddate”).setSensitiveRange(value, null);
}
}

///getClient.jsp///

<?xml version="1.0" encoding="ISO-8859-1"?>

-

DB0002D10010090

2016-01-01

2016-12-31

Hi

Could you please provide us complete demo including all correspondnig js/css files?
Please also add information regarding current and expected behaviour.

Here is a small guide how to make a complete demo:
docs.dhtmlx.com/tutorials__auxil … pport.html

If you don’t want to share your demo here for any reasons - you can send it to support@dhtmlx.com, if so - please include link to this forum topic.

If you’re using PRO Edition please send your demo to support@dhtmlx.com