function tomForm(div) { this.div = div; this.id = div.getAttribute("id2"); this.height = parseInt(this.div.style.height); this.divStatus = gEL2(this.div,"Status"); this.divInh = gEL2(this.div,"inhalt"); this.divErr = gEL2(this.div,"Err"); if(this.debug==true) { var obj = this; var el = document.createElement('input'); el.value = "Sho Formdata"; el.type = "button"; el.onclick = function() {obj.showFormdata()}; div.appendChild(el); } this.frmID = div.getAttribute("frmID"); this.meldungsubmit = div.getAttribute("meldungsubmit"); this.meldungafter = div.getAttribute("meldungafter"); this.focus = getWert(div.getAttribute("focus")); this.url = "/_gui/_ components/formular/xForm.asp"; this.picDone = new Image(); this.picDone.src = ""; this.initSubmitbutton(); this.sav = new saveForm(this.div); this.setFocus(); this.reset(); } tomForm.prototype.init = function() { } tomForm.prototype.setHeight = function(y) { this.div.style.height = y+"px"; } tomForm.prototype.initSubmitbutton = function() { var obj = this; var els = this.div.getElementsByTagName("div"); for(var i = 0; i < els.length; i++) { var el = els[i]; if(el.getAttribute("id2")=="cmdSubmit") { var fn = function() { obj.submit() }; el.onclick = fn; } } } tomForm.prototype.status = function(txt) { this.divStatus.innerHTML = txt; } tomForm.prototype.submit = function() { if(this.isFormValid()) { if(this.gui) { if(this.gui[this.id+"_onSubmit"]) { rc = this.gui[this.id+"_onSubmit"](); if(rc == false) return; //data += this.gui[this.id+"_onSubmit"]() } } var meldung = this.meldungsubmit; if(meldung=="") meldung="Einen Moment bitte .."; meldung = ""+meldung; setVisible(this.divErr,false); setVisible(this.divInh,false); setVisible(this.divStatus,true); this.status(meldung); var data = this.getformdata(); xmlhttp(this.url,data,this.doneSubmit,"",this); }else{ return false; } } tomForm.prototype.getformdata = function() { var data = this.sav.getAll(); data += "&webname="+web.webname+"&lang="+web.lang+"&frmID="+this.frmID; if(web.tvb) data += "&tvb=1"; return data; } tomForm.prototype.visible = function(cod) { setVisible(this.div,cod); } tomForm.prototype.clear = function() { this.sav.clear(); } tomForm.prototype.reset = function() { setVisible(this.divInh,true); setVisible(this.divStatus,false); setVisible(this.divErr,false); } tomForm.prototype.error = function(err) { setVisible(this.divErr,true); setContent(this.divErr,err); } tomForm.prototype.doneSubmit = function(ret) { dodebug(ret); var ok = getOK(ret); if(ok) { var meldung = getWert(this.meldungafter); if(!meldung=="") { meldung += "
"; }else{ meldung = ok; } setVisible(this.divStatus,true); setContent(this.divStatus,meldung); //this.clear(); raiseevent(this,"doneSubmit",ret); }else{ var err = retXP(ret,"err"); if(err) { this.reset(); this.error(err); }else{ showError("tomForm.doneSubmit",ret); } } } tomForm.prototype.setFocus = function(feldname) { if(!feldname) return; var rc = this.setFocusTyp(feldname,"input"); if(!rc) rc = this.setFocusTyp(feldname,"textarea"); } tomForm.prototype.setFocusTyp = function(feldname,typ) { var found = false; var txt = this.div.getElementsByTagName(typ); for (var i = 0; i < txt.length; i++) { if(txt[i].name == feldname) { //try { txt[i].focus() } catch(ex) { /* do nothing */ } txt[i].focus(); found = true; } } return found; } tomForm.prototype.isFormValid = function() { var fehler = ""; var felder = ""; var fEmail = ""; var rc = this.validate("input"); felder = rc.felder; fEmail = rc.email; var rc = this.validate("textarea"); felder += rc.felder; var nuFelder = this.sortFelder(felder) var nu = ""; for (var i = 0; i < nuFelder.length-1; i++) { nu += nuFelder[i].feld+"\n"; } fehler = nu+fEmail; if(!fehler.length == 0) { var capt = unescape("Bitte f%FCllen Sie folgende Felder aus:\n"); fehler = capt+fehler; alert(fehler); this.setFocus(nuFelder[0].feld); return false; }else{ // OK return true; } } tomForm.prototype.sortFelder = function(felder) { var nuFelder = new Array; var fe = felder.split("\n"); for (var i = 0; i < fe.length; i++) { var feld = fe[i]; var t = feld.split("|"); nuFelder[nuFelder.length++] = new this.addFormfeld(t[0],t[1]); } nuFelder.sort(this.Numsort); return nuFelder; } tomForm.prototype.addFormfeld = function(feld,tabindex) { this.tabindex = tabindex; this.feld = feld; } tomForm.prototype.Numsort =function(a, b) { var x = a.tabindex; var y = b.tabindex; return ((x < y) ? -1 : ((x > y) ? 1 : 0)); } tomForm.prototype.validate = function(feldtyp) { var fEmail=""; var mfelder=""; var inp = this.div.getElementsByTagName(feldtyp); for (var i = 0; i < inp.length; i++) { var obj = inp[i]; var vali = obj.getAttribute("validate"); var typ = obj.getAttribute("typ"); var feld = obj.name.toLowerCase(); if(vali==1) { obj.style.background = ""; var inh = obj.value; if (getWert(inh)=="") { obj.style.background = "yellow"; mfelder += obj.name + "|"+obj.tabIndex+"\n"; }else{ if(feld.search('email')!=-1) { rc = this.chkEmail(inh); if (rc!="") { obj.style.background = "yellow"; fEmail += rc + "\n"; } } } } if(feld=="von" || feld=="bis") { var inh = obj.value; var t = inh.split("."); if(t.length!=3) { fEmail += unescape("Datum "+feld+" ist ung%FCltig! (Punkt vergessen?)\n"); } } } return {felder: mfelder,email: fEmail}; } tomForm.prototype.chkEmail = function(feld) { var fehler=''; var mail=feld; if(feld.value=="") { return; } else { if(mail.search(' ')!=-1) { //fehler = "Ihre Emailadresse enthält ein Leerzeichen!" } at_pos=mail.indexOf("@") dot_pos=mail.indexOf(".") if(at_pos<1 || dot_pos<1) { fehler = unescape("Emailadresse ung%FCltig! %DCberpr%FCfen Sie die Schreibweise - Problem mit @ und ."); } else { condition="yes" var at_count=0 var dot_count=0 var temp=0 for(var i=0;i0 && mail.charCodeAt(i)<48)||(mail.charCodeAt(i)>57 && mail.charCodeAt(i)<65)||(mail.charCodeAt(i)>91 && mail.charCodeAt(i)<97)||mail.charCodeAt(i)>122) { if(mail.charAt(i)=="@"||mail.charAt(i)=="."||mail.charAt(i)=="-"||mail.charAt(i)=="_") { if(mail.charAt(i)=="@") { at_count++ }else{ dot_count++ } // counts the no. of times @ and . appears in email if(dot_count>=1) { dot_pos=i if((dot_pos>at_pos) && temp==0) { pos=dot_pos-at_pos temp++ } } } else { condition="no" i=mail.length } } } if(condition=="no") { fehler = "Ihre Emailadresse enthält ein Leerzeichen oder ungültiges Zeichen!"; } else { if(at_count>1) { fehler = "Emailadresse darf nur einmal @ enthalten!" } else { if(pos<2) { fehler = "Emailadresse: Domain zwischen '@' und '.' fehlt!"; i=mail.length } else { count=dot_pos+1 domain="" for(count;count3)) || (domain.length<2)) { fehler = "Emailadresse: Domainendung nach '.' ungültig! (Muss mind. 2 Zeichen lang sein)"; } } } } } } return fehler; } tomForm.prototype.showFormdata = function() { var data = this.getformdata(); var t = data.split("&"); var nu = "
"; nu += "" for(var i=0;i< t.length;i++) { var d = t[i].split("="); var wert = unescape(d[1]); if(wert=="") wert = " "; nu += ""; } nu +="
"+d[0]+""+wert+"
"; setContent("divdebug",nu); } tomForm.prototype.setDates = function() { var von = gELbyName(this.div,"von"); von.value = get_heute(); var bis = gELbyName(this.div,"bis"); bis.value = get_morgen(); } function gELbyName(div,id) { ctl = gELbyNameCTL(div,id,"input"); if(!ctl) ctl = gELbyNameCTL(div,id,"select"); return ctl; } function gELbyNameCTL(div,id,typ) { var el = div.getElementsByTagName(typ); for (var i = 0; i < el.length; i++) { if(el[i].name==id) { return el[i]; break; } } } function get_heute() { var dat = new Date(); var tag= dat.getDate(); var monat= dat.getMonth()+1; var jahr= dat.getFullYear(); return tag + "."+monat+"."+jahr } function get_morgen() { var Zeit = new Date(); var jetztZeit = Zeit.getTime(); var morgen = jetztZeit + (1000*60*60*24); Zeit.setTime(morgen); var Tag = Zeit.getDate(); var Monat = Zeit.getMonth()+1; var Jahr = Zeit.getFullYear(); return(Tag+"."+Monat+"."+Jahr) }