/* types */ Validator.types = { 'postalcode': { check: function(elm){ regexpr =/^\d{4}[ ]{0,1}[A-Za-z]{2}$/; return regexpr.test(elm.value); }, format: function(elm){ }, /* action */ event: "onblur", /* error message */ message: "Postcode moet zijn : 1234 AB" }, 'login' : { check: function(elm){ regexpr =/^[A-Z0-9]*$/; return regexpr.test(elm.value); }, format: function(elm){ elm.value=elm.value.toUpperCase(); }, /* action */ event: "onblur", /* error message */ message: "Loginnaam mag alleen bestaan uit de tekens : A-Z, 0-9." }, /* return a trimed string and uppercase the first letter */ 'ucfirst' : { check: function(elm){ return true; }, format: function(elm) { var val = elm.value; if (val.length > 0) { //trim val = val.replace(/^\s*|\s*$/g,""); val = val.toLowerCase(); var first = val.charAt(0).toUpperCase(); val = first + val.substr(1); elm.value=val; } }, /* action */ event: "onblur" }, /* return a trimed string and lowercase string */ 'lowercase' : { check: function(elm){ return true; }, format: function(elm) { var val = elm.value; if (val.length > 0) { //trim val = val.replace(/^\s*|\s*$/g,""); val = val.toLowerCase(); elm.value=val; } }, /* action */ event: "onblur" }, 'email' : { check: function(elm){ regexpr =/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regexpr.test(elm.value); }, format: function(elm){ }, /* action */ event: "onblur", /* error message */ message: "Ongeldig e-mail adres." }, 'amount' : { check: function(elm){ amount=/^([0-9]{1,3})(\.?[0-9]{3})*(,?[0-9]{1,2}){0,1}$/; return amount.test(elm.value); }, format: function(elm){ if (!elm.value) return false; cBedrag = elm.value; cBedrag = cBedrag.replace(/\.{1}(\d{1,2})$/g,",$1"); var tmpArray = cBedrag.split(','); var cGuld = tmpArray[0].replace(/\./g,''); if (tmpArray[1]) { var cCent = tmpArray[1].substring(0,2); if (cCent.length == 1) cCent = cCent + "0"; } else { var cCent = "00"; } if (tmpArray.length < 3) { var ctBedrag = ""; while ((nLengte = cGuld.length) > 3) { var ctBedrag = "." + cGuld.substring(nLengte - 3,nLengte) + ctBedrag; cGuld = cGuld.substring(0,nLengte - 3); } ctBedrag = cGuld + ctBedrag; elm.value = ctBedrag + "," + cCent; } }, /* action */ event: "onblur", /* error message */ message: "adfdsf" } }; /* error display handling */ Validator.display = { /* show an error 'thing' for the active field */ 'error' : function(item) { if (item.itemErrorchanged == true) { item.itemReplaced = document.createElement("div"); item.itemReplaced.innerHTML='
