MINI
C:
/
SiakApp
/
web
/
CatatanSipilAssets
/
js
/
Upload File:
files >> C:/SiakApp/web/CatatanSipilAssets/js/capilValidate.js
function validateMaxLength() { input = document.getElementsByTagName("input"); for (i = 0; i != input.length; i++) { if (input[i].maxLength && input[i].type=='text') { if (input[i].value.length > input[i].maxLength) { alert("Maaf, ada ganjalan sedikit, periksalah isian anda kembali! \nAda pengisian form yang melebihi kapasitas."); input[i].className = "errorHighlight"; input[i].focus() return false; break; } } } return true; } function validateKey(objectId) { if (actionGet(objectId + "_ada")=="2") { if (actionLength(objectId, 16, "EQUAL") != true) return false; else return true } else return true; } function validateDate(objectId) { if (!actionGet(objectId + "_day") && !actionGet(objectId + "_month") && !actionGet(objectId + "_year")) { actionHighlight(objectId + "_day"); actionHighlight(objectId + "_month"); actionHighlight(objectId + "_year"); return false; } else { var d=new Date(); d.setFullYear(parseInt(actionGet(objectId + "_year"),10),parseInt(actionGet(objectId + "_month"), 10)-1,parseInt(actionGet(objectId + "_day"), 10)); var tanggal_valid=d.getDate().toString()+'-'+(d.getMonth()+1).toString()+'-'+d.getFullYear().toString(); var tanggal=parseInt(actionGet(objectId + "_day"), 10).toString()+'-'+parseInt(actionGet(objectId + "_month"), 10).toString()+'-'+parseInt(actionGet(objectId + "_year"),10).toString(); if (actionLength(objectId + "_day", 1, "LESS")) { actionHighlight(objectId + "_day"); return false; } else if (actionLength(objectId + "_month", 1, "LESS")) { actionHighlight(objectId + "_month"); return false; } else if (actionLength(objectId + "_year", 4, "LESS")) { actionHighlight(objectId + "_year"); return false; } else if(tanggal!=tanggal_valid){ actionHighlight(objectId + "_day"); actionHighlight(objectId + "_month"); actionHighlight(objectId + "_year"); return false; } else if (parseInt(actionGet(objectId + "_day"), 10) < 1 || parseInt(actionGet(objectId + "_day"), 10) > 31) { actionHighlight(objectId + "_day"); return false; } else if (parseInt(actionGet(objectId + "_month"), 10) < 1 || parseInt(actionGet(objectId + "_month"), 10) > 12) { actionHighlight(objectId + "_month"); return false; } else if (parseInt(actionGet(objectId + "_year"), 10) < 1850 || parseInt(actionGet(objectId + "_year"), 10) > 2100) { actionHighlight(objectId + "_year"); return false; } else return true; } } function validateDateParent(objectId) { var d=new Date(); d.setFullYear(parseInt(actionGet(objectId + "_year"),10),parseInt(actionGet(objectId + "_month"), 10)-1,parseInt(actionGet(objectId + "_day"), 10)); var tanggal_valid=d.getDate().toString()+'-'+(d.getMonth()+1).toString()+'-'+d.getFullYear().toString(); var tanggal=parseInt(actionGet(objectId + "_day"), 10).toString()+'-'+parseInt(actionGet(objectId + "_month"), 10).toString()+'-'+parseInt(actionGet(objectId + "_year"),10).toString(); if (actionLength(objectId + "_day", 1, "LESS")) { actionHighlight(objectId + "_day"); return false; } else if (actionLength(objectId + "_month", 1, "LESS")) { actionHighlight(objectId + "_month"); return false; } else if (actionLength(objectId + "_year", 4, "LESS")) { actionHighlight(objectId + "_year"); return false; } else if(tanggal!=tanggal_valid){ actionHighlight(objectId + "_day"); actionHighlight(objectId + "_month"); actionHighlight(objectId + "_year"); return false; } else if (parseInt(actionGet(objectId + "_day"), 10) < 1 || parseInt(actionGet(objectId + "_day"), 10) > 31) { actionHighlight(objectId + "_day"); return false; } else if (parseInt(actionGet(objectId + "_month"), 10) < 1 || parseInt(actionGet(objectId + "_month"), 10) > 12) { actionHighlight(objectId + "_month"); return false; } else if (parseInt(actionGet(objectId + "_year"), 10) > 2100) { actionHighlight(objectId + "_year"); return false; } else return true; } function validateDay(objected, event) { validateInteger(objected.id); var value = parseInt(objected.value, 10); objected.className=''; if (actionLength(objected.id, 2, "LESS")) { actionHighlight(objected.id); return false; } if (value < 1 || value > 31) { objected.value = ""; actionError(objected.id, "Maaf, Pengisian Tanggal Salah!"); $('box_error').fade({duration: 4.0}); actionHighlight(objected.id); return false; } else return actionGoNext(objected, event); } function validateMonth(objected, event) { validateInteger(objected.id); var value = parseInt(objected.value, 10); objected.className=''; if (actionLength(objected.id, 2, "LESS")) { actionHighlight(objected.id); return false; } if (value < 1 || value > 12) { objected.value = ""; actionError(objected.id, "Maaf, Pengisian Bulan Salah!"); $('box_error').fade({duration: 4.0}); actionHighlight(objected.id); return false; } else return actionGoNext(objected, event); } function validateYear(objected, event) { validateInteger(objected.id); var value = parseInt(objected.value, 10); objected.className=''; if (actionLength(objected.id, 4, "LESS")) { actionHighlight(objected.id); return false; } if (value < 1850 || value > 2100) { objected.value = ""; actionError(objected.id, "Maaf, Pengisian Tahun Salah!"); $('box_error').fade({duration: 4.0}); actionHighlight(objected.id); return false; } else return actionGoNext(objected, event); } function validateDateIncidental(objectId) { var ret = true; if (actionGet(objectId + "_day") || actionGet(objectId + "_month") || actionGet(objectId + "_year")) { if (!actionGet(objectId + "_day")) { actionHighlight(objectId + "_day"); ret = false; } if (!actionGet(objectId + "_month")) { actionHighlight(objectId + "_month"); ret = false; } if (!actionGet(objectId + "_year")) { actionHighlight(objectId + "_year"); ret = false; } if (parseInt(actionGet(objectId + "_day"), 10) < 1 || parseInt(actionGet(objectId + "_day"), 10) > 31) { actionHighlight(objectId + "_day"); ret = false; } if (parseInt(actionGet(objectId + "_month"), 10) < 1 || parseInt(actionGet(objectId + "_month"), 10) > 12) { actionHighlight(objectId + "_month"); ret = false; } if (parseInt(actionGet(objectId + "_year"), 10) < 1850 || parseInt(actionGet(objectId + "_year"), 10) > 2100) { actionHighlight(objectId + "_year"); ret = false; } } return ret; } function validateNik(objectId) { if (actionGet(objectId) < 16 && actionGet(objectId + '_ada')==2) return false; else return true; } function validateAge(objectId, ages) { if (actionGet(objectId + '_umur') < ages && actionGet(objectId + '_nama')) return false; else return true; } function setValidateResponse(err) { var msg = "Kesalahan : \n\n"; if (err.length > 0) { var os; for(var i = 0; i < err.length; i++) { var obj = err[i].split("|"); if (i == 0) os = obj[0]; actionHighlight(obj[0]); msg += (i + 1) + ". " + obj[1] + "\n"; } alert(msg); actionFocus(os); } } function validateInteger(obj) { if (!actionCheckInteger(obj)) { actionHighlight(obj); actionError(obj, "Maaf, Hanya Angka yang diperbolehkan!"); $('box_error').fade({duration: 4.0}); actionObject(obj).value = ""; } } function setEnableElement() { input = document.getElementsByTagName("input"); for (i = 0; i != input.length; i++) { input[i].disabled = false; } sel = document.getElementsByTagName("select"); for (i = 0; i != sel.length; i++) { sel[i].disabled = false; } } function validateDateMoreThan(dateFirstPrefix, dateNextPrefix) { var firstDay = actionGet(dateFirstPrefix + '_day'); var firstMonth = actionGet(dateFirstPrefix + '_month'); var firstYear = actionGet(dateFirstPrefix + '_year'); var nextDay = actionGet(dateNextPrefix + '_day'); var nextMonth = actionGet(dateNextPrefix + '_month'); var nextYear = actionGet(dateNextPrefix + '_year'); if (firstDay.length < 2) firstDay = '0' + firstDay; if (firstMonth.length < 2) firstMonth = '0' + firstMonth; if (nextDay.length < 2) nextDay = '0' + nextDay; if (nextMonth.length < 2) nextMonth = '0' + nextMonth; var dateFirst = firstYear + '' + firstMonth + '' + firstDay; var dateNext = nextYear + '' + nextMonth + '' + nextDay; if (parseInt(dateNext) < parseInt(dateFirst)) return false; else return true; } function validateSameNik(firstPrefix, nextPrefix) { if (actionGet(firstPrefix + '_nik') && actionGet(nextPrefix + '_nik')) { if (actionGet(firstPrefix + '_nik') == actionGet(nextPrefix + '_nik')) return false; else return true; } else return true; } function validateDateMoreThanNow(dateFirstPrefix) { var firstDay = actionGet(dateFirstPrefix + '_day'); var firstMonth = actionGet(dateFirstPrefix + '_month'); var firstYear = actionGet(dateFirstPrefix + '_year'); var date = new Date(); var nextDay = date.getDate(); var nextMonth = date.getMonth()+1; var nextYear = date.getFullYear(); if (firstDay.length < 2) firstDay = '0' + firstDay; if (firstMonth.length < 2) firstMonth = '0' + firstMonth; if (nextDay < 10) nextDay = '0' + nextDay; if (nextMonth < 10) nextMonth = '0' + nextMonth; var dateFirst = firstYear + '' + firstMonth + '' + firstDay; var dateNext = nextYear + '' + nextMonth + '' + nextDay; if (parseInt(dateNext) < parseInt(dateFirst)) return false; else return true; } function validateAgeMoreThan(dateFirstPrefix, age) { var firstYear = actionGet(dateFirstPrefix + '_year'); var date = new Date(); var nextYear = date.getFullYear(); var umur = nextYear - firstYear; if (umur < age) return false; else return true; }
Copyright ©2021 || Defacer Indonesia