Created
September 29, 2011 16:31
-
-
Save dbowling/1251178 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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