//Validierungsmethoden var alphanumeric="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; var umlaut="ÄÖÜäöüß"; var numeric="0123456789"; function checkDate(str) { var result=""; var pos1=str.indexOf('.'); var pos2=str.lastIndexOf('.'); if (pos1&&pos1>-1&&pos2&&pos2>pos1&&str.length>pos2) { var day=str.substring(0,pos1); if (day&&day>=1&&day<=31) { var month=str.substring(pos1+1,pos2); if (month&&month>0&&month<=12){ var year=str.substring(pos2+1); if (year<=30) year='20'+year; if (year>30&&year<100) year='19'+year; var d=Date.parse(month+" "+day+" "+year); var date=new Date(d); var now = new Date(); var diff =now-date; jahre=Math.floor(diff/(24*3600*1000*365)); if (jahre>100) return "Das Datum ist syntaktisch korrekt, aber nicht plausibel. Bitte überprüfen Sie Ihre Eingabe (Eingebenes Alter="+jahre+")!"; if (jahre<18) return "Sie sind jünger als 18 Jahre und dürfen gar nicht bestellen..."; } } } return ""; } function check(str, validChars) { for (var i = 0; i < str.length; i++) { j = str.charAt(i); if (validChars.indexOf (j) == -1) { return false; } } return true; } jQuery.validator.addMethod( "geburtsdatum", function(value, element) { var check=checkDate(element.value); if (check.length>0) { return false; } else { return true; } } ); jQuery.validator.addMethod( "datum", function(value, element) { return element.value.length==10; }, 'Keine gültiges Datum!' ); jQuery.validator.addMethod( "telefon", function(value, element) { validChars = numeric+"/-+ "; return check(element.value, validChars); } ); jQuery.validator.addMethod( "plz", function(value, element) { validChars = numeric; return (check(element.value, validChars) && element.value.length==5); } ); jQuery.validator.addMethod( "strasse", function(value, element) { validChars = numeric+alphanumeric+umlaut+"/.- "; return check(element.value, validChars); } ); jQuery.validator.addMethod( "nname", function(value, element) { validChars = alphanumeric+umlaut+"-. "; return check(element.value, validChars); } ); jQuery.validator.addMethod( "firma", function(value, element) { validChars = alphanumeric+umlaut+".-+&/ "; return check(element.value, validChars); } ); jQuery.validator.addMethod( "password", function(value, element) { return element.value.length>=3; }, 'Das Passwort muss mindestens 3 Zeichen lang sein!' ); jQuery.validator.addMethod( "bestellmenge", function(value, element) { return element.value.length <= 3 && check(element.value, numeric+" "); }, 'Keine gültige Anzahl!' );