/** * * @access public * @return void **/ function checkUserinfo() { var asErrors = new Array(); if (!document.getElementById('EMail').value){ asErrors['EMail'] = 'Sinun täytyy ilmoittaa sähköpostiosoite'; } else if(!isValidEmail(document.getElementById('EMail').value)){ asErrors['EMail'] = 'Sähköpostiosoite ei ole voimassa'; } else{ valid="@.0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'*+-/=?^_`{|}~., "; for (var i=0; i 0){ datevalid = validateDate(document.getElementById('Birthdate').value, 2); if(datevalid == "ERR"){ asErrors['Birthdate'] = 'Olet ilmoittanut virheellisen päivämäärän, haluttu järjestys on pv.kk.vuosi '; } else document.getElementById('Birthdate').value = datevalid; } return asErrors; } function checkPassword() { var asErrors = new Array(); if (!document.getElementById('OldPassword').value){ asErrors['OldPassword'] = 'Sinun täytyy ilmoittaa tämänhetkinen salasanasi'; } if (!document.getElementById('Password').value){ asErrors['Password'] = 'Sinun täytyy ilmoittaa salasana'; }else{ valid="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'*+-/=?^_`{|}~ "; for (var i=0; i 0){ datevalid = validateDate(document.getElementById('Birthdate').value, 2); if(datevalid == "ERR"){ asErrors['Birthdate'] = 'Olet ilmoittanut virheellisen päivämäärän, haluttu järjestys on pv.kk.vuosi '; } else document.getElementById('Birthdate').value = datevalid; } return asErrors; } function isValidEmail(str) { /*var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; if (!filter.test(str)) return false;*/ return (str.indexOf(".") > 0) && (str.indexOf("@") > 0); } function fnIntValue(field, e) { if (window.event) { key = window.event.keyCode; } else if(e) { key = e.which; } else { return true; } keychar = String.fromCharCode(key); // control keys if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ) { return true; } // numbers else if ((("0123456789").indexOf(keychar) > -1)) { return true; } else { return false; } } var errors; function saveUser(form) { if(document.getElementById('btnSavepwd')) document.getElementById('btnSavepwd').disabled=true; if(document.getElementById('SaveButton')) document.getElementById('SaveButton').disabled=true; if (errors){ for (var s in errors){ if(document.getElementById(s+'Error')) document.getElementById(s+'Error').innerHTML = ''; } } if (form == 'passwordForm'){ errors = checkPassword(); } else if (form == 'accountForm'){ errors = checkAccount(); } else{ errors = checkUserinfo(); if(jcap() == false){ if(document.getElementById('btnSavepwd')) document.getElementById('btnSavepwd').disabled=false; if(document.getElementById('SaveButton')) document.getElementById('SaveButton').disabled=false; return; } } var i=0; for (var s in errors){ if(document.getElementById(s+'Error')){ document.getElementById(s+'Error').innerHTML = errors[s]; i++; } } if (i > 0){ if(document.getElementById('btnSavepwd')) document.getElementById('btnSavepwd').disabled=false; if(document.getElementById('SaveButton')) document.getElementById('SaveButton').disabled=false; return; } document.getElementById(form).submit(); } function SendPwdReminder() { if(errors) { for (var s in errors) { if(document.getElementById('errmsg'+s)) { document.getElementById('errmsg'+s).innerHTML = ' '; } } } var asErrors = new Array(); if (!document.getElementById('EMail').value) { asErrors['001'] = 'Sinun täytyy ilmoittaa sähköpostiosoitteesi'; } else if(!isValidEmail(document.getElementById('EMail').value)) { asErrors['001'] = 'Ilmoittamasi sähköpostiosoite on virheellinen'; } errors = asErrors; var i=0; for (var s in errors) { if(document.getElementById('errmsg'+s)) { document.getElementById('errmsg'+s).innerHTML = errors[s]; i++; } } if (i > 0) { return; } document.getElementById('registerForm').submit(); } // // Input can be // dd.mm.yyyy // yyyy-mm-dd // mm/dd/yyyy // yy are considered 19yy // m and d are ok // // Returned date format // iType 1 - yyyy-mm-dd (ISO 8601) // 2 - dd.mm.yyyy // 3 - mm/dd/yyyy // // Remember that months used in these functions are 0-11 // function validateDate(obj, iType) { var sDate; var sType; var sResult; // Determine which date format is being used based on the separator. // If no valid separator is found, assume format is DMY. if (obj.indexOf ('.', 0) != -1) sType = "DMY"; if (obj.indexOf ('-', 0) != -1) sType = "YMD"; if (obj.indexOf ('/', 0) != -1) sType = "MDY"; if (!sType) { sType = "YMD"; sDate = obj.substr(4, 4) + "-" + obj.substr(2, 2) + "-" + obj.substr(0, 2); } else sDate = obj; // Now convert to YMD (ISO 8601) if (sType=="DMY") { sYMD = sDate.split('.').reverse().join('-'); if(sDate.split('.').length!=3) return "ERR"; } if (sType=="MDY") { sYMD = sDate.replace(/(\d+)\/(\d+)\/(\d+)/, "$3-$1-$2") if(sDate.split('/').length!=3) return "ERR"; } if (sType=="YMD") { sYMD = sDate; if(sDate.split('-').length!=3) return "ERR"; } // Split date into parts var asDateParts = sYMD.split('-'); // Create date object var iMonth = asDateParts[1] - 1; var dDate = new Date(asDateParts[0], iMonth, asDateParts[2]); // Verify that month and day are with in valid range if ((dDate.getDate()==asDateParts[2]) && (dDate.getMonth()==iMonth)) { if (isNaN(dDate.getFullYear())) sResult = "ERR"; else { var sYear = dDate.getFullYear(); var sMonth = dDate.getMonth()+1; if ((dDate.getMonth()+1)<10) sMonth = '0' + sMonth; var sDay = dDate.getDate(); if (dDate.getDate()<10) sDay = '0' + sDay; // Create return value based on parameter if (iType==1) sResult = sYear + '-' + sMonth + '-' + sDay; if (iType==2) sResult = sDay + '.' + sMonth + '.' + sYear; if (iType==3) sResult = sMonth + '/' + sDay + '/' + sYear; } } else sResult = "ERR"; var birthpattern = new RegExp(/^(0[1-9]|[12][0-9]|3[01])\.(0[1-9]|1[012])\.(19|20)\d\d$/); if(!birthpattern.test(sResult)) sResult = "ERR"; return sResult; }