Friday, July 4, 2008

Custom validation and messages

Once again, Cruxade's validation library have been improved to allow cleaner code for custom validations and error message. The snippet below was taken from chrome://cruxade/content/validation.xul

var lv_oContainer = cruxade_ExtendContainer("container");
var lv_aValidator = [];
_validate_ : "required :vCustomFunc",
_errmessage_: function(nErrCode){
if (nErrCode==10) return "Max Error number?";
return "custommessage";
// return 0 if no error
return 10; // test case error
_validate_ : "required typedigit",
if (nErrCode==2) return "Please give me a number.";

Feel like hacking the code..?

The uda_validate options ":v" still works. ":m" is deprecated. Shall we carry on with the ":m" option? Tell me what you think.