// 2004-06-05 joel // Form validation routines function ct_verify_input(oinput,cond,msg,p1,p2,p3) { var result=true; var isArr=(typeof oinput=='object' && !oinput.tagName); if (!isArr && oinput.tagName!='INPUT' && oinput.tagName!='SELECT' && oinput.tagName!='TEXTAREA') alert('ct_verify_input js error: not an input entity'); // 2006-10-24 joel if (typeof ctfv_str=="undefined") { alert('ct_verify_input js error: developer pls include language js (eg. /site/ctx/js/.pcache.fv_str.js)'); return false; } // default checking if (!cond) cond='fill'; if (!isArr) { // get the display name for field fdn=(oinput.dname || oinput.name); } //alert(cond+'/'+fdn+'/'+oinput.value+'/'); if (cond=='fill') { if (oinput.value=='') { if (!msg) msg=(ctfv_str.need_value)+'['+fdn+']'; result=false; } } else if (cond=='radios') { cnt=oinput.length; result=0; if (!p1) p1=1; for(var i=0; i< cnt; i++) { if (oinput[i].checked) result++; } if (resultp2) { msg=(ctfv_str.need_number)+'['+fdn+']'+'\n('+(ctfv_str.number_range)+p1+' - '+p2+')'; result=false; } } else if (cond=='phone') { // 2004-09-24 joel if (oinput.value=='' || isNaN(oinput.value) || oinput.value.length<8) { msg=(ctfv_str.need_phone)+'['+fdn+']'; msg+='\n('+(ctfv_str.phone_explain)+')'; result=false; } } else if (cond=='email') { p=oinput.value.indexOf('@'); if (p<1 || p==(oinput.value.length-1)) { if (!msg) msg=(ctfv_str.need_email)+'['+fdn+']'; result=false; } } else if (cond=='confirm_pw') { if (oinput.value!=p1.value) { if (!msg) msg=(ctfv_str.bad_pw_verify)+'['+fdn+']'; result=false; } } else if (cond=='disallow_ext' || cond=='limit_ext') { // ec: restricted ext var earr=p1.split(","); if (oinput && earr) { var f=oinput.value; for(var i=0; iodate2.value) { alert("Please enter a "+dn2+" date which is later than the "+dn1+" date."); odate2.focus(); return false; } return true; } function ct_dirty_input(oinput) { document.body.ct_dirty_form=true; oinput.style.backgroundColor='#FFD7D7'; barr=document.getElementsByTagName('INPUT'); for (i=0; barr!=null && i