Skip to content

Instantly share code, notes, and snippets.

@dbowling
Created September 29, 2011 16:31
Show Gist options
  • Save dbowling/1251178 to your computer and use it in GitHub Desktop.
Save dbowling/1251178 to your computer and use it in GitHub Desktop.
dojo.addOnLoad(function(){
dijit.registry.byClass("dijit.form.DateTextBox").forEach(function(w){
if(w.class == 'hugDatePicker'){
w.validator = function(value, constraints){
var deferred = isValidDate(value);
return deferred.then(function(value){
console.log(value);
if(value.indexOf("OK") != -1){
return true;
}else{
w.displayMessage(value);
return false;
}
},
function(error){
console.log(error);
return false;
});
}
}
});
});
function isValidDate(date){
var xhrArgs = {
url: site_url + '/hugs/validateDeliveryDate',
content: {
"date":date,
"csrf_bear_hugs": csrf_hash,
},
timeout: 2000,
load: function(data) {
return data;
},
error: function(error) {
console.log(error);
}
}
var deferred = dojo.xhrPost(xhrArgs);
//console.log(deferred);
return deferred;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment