function sendRequest(el) { var silentId = document.getElementById("silent"); var innerTag = ""; if(silentId && el && el.href) { var uri = el.href.split("?"); var cnt = null; var pair = null; if(uri[1]) { cnt = uri[1].split("&"); for(var i = 0; i < cnt.length; i++) { pair = cnt[i].split("="); innerTag += ""; } silentId.action = uri[0]; silentId.innerHTML = innerTag; setTimeout("document.forms['silent'].submit()", 100); } } return false; } function futureDayJS(dateVar, numDay) { var inputDate = dateVar.split("/"); var dateObj = new Date(inputDate[2], inputDate[1]-1, inputDate[0], 01, 01, 01, 01); var futureDay = new Date(Date.parse(dateObj) + (numDay * 24 * 60 * 60 * 1000)); var str = "0"; var dd = String(futureDay.getDate()); var mm = String(futureDay.getMonth() + 1); if(dd.length < 2) dd = str.concat(dd); if(mm > 12) mm = 12; if(mm.length < 2) mm = str.concat(mm); return dd+"/"+mm+"/"+futureDay.getFullYear(); } function checkWeekDayJS(dateVar, weekDayVar) { var inputDate = dateVar.split("/"); if(typeof(inputDate[2]) != "undefined") { //new Date(year, month, day, hours, minutes, seconds, milliseconds) dateObj = new Date(inputDate[2], inputDate[1]-1, inputDate[0], 01, 01, 01, 01); if(dateObj.getDay() == weekDayVar) return true; else return false; } return false; } function isDate (dd, mm, yy, msg) { if((mm==4 || mm==6 || mm==9 || mm==11) && dd==31) { alert(msg); return false; } if(mm==2) { var isLeap = (yy % 4 == 0 && (yy % 100 != 0 || yy % 400 == 0)); if (dd > 29 || (dd==29 && !isLeap)) { alert(msg); return false; } } return true; } function autotab(original, destination){ if (original.getAttribute && original.value.length==original.getAttribute("maxlength")) destination.focus(); } function diff2Dates(f) { var date1 = f.startDate.value.split("-"); var date2 = f.endDate.value.split("-"); //Set the two dates date1 = new Date(eval(date1[2]), eval(date1[1]-1), eval(date1[0])); date2 = new Date(eval(date2[2]), eval(date2[1]-1), eval(date2[0])); //Month is 0-11 in JavaScript //Set 1 day in milliseconds var one_day = 1000*60*60*24; //Calculate difference btw the two dates, and convert to days var diff = Math.ceil((date2.getTime()-date1.getTime())/(one_day)); if(diff < 0) { alert("วันที่ไม่สัมพันธ์กัน"); return false; } f.dayAmount.value = diff+1; } function doCheckAll(form,do_check){ for (var i=0; i StopDay) { alert(msg); retval = false; } return retval; } function checkFormat(txtStart, txtEnd) { //alert("enter checkFormat"); if (txtStart && txtEnd) { //alert("receive 2 variable"); var oblen = txtStart.length; for (var i = 0; i < oblen; i++) { if (!isvaliddate(txtStart[i], txtEnd[i])) { return false; } } return true; } } //--- เช็คว่ากรอกข้อมูลได้เฉพาะตัวเลข --- //--- ใช้ในหน้าวิว onKeyDown="document.onkeydown=check_number" ---- function check_number(e) { var key; if (window.event) key = window.event.keyCode; // ใช้กับ IE else if (e) key = e.which; // ใช้กับ Firefox if (key = 13 && key != 8 && key != 9 && key != 16 && key != 17 && key != 20 && key != 35 && key != 36 && key != 46 && (key < 48) || (key > 57) && (key < 96) || (key > 105) && key != 116) { //alert(key); return false; } } //--- เช็คการกรอกข้อมูลที่กรอกได้เฉพาะตัวเลข --- function keyCode(evt){ var key = (evt.which) ? evt.which : event.keyCode if (key < 48 || key > 57) return false; else return true; } jQuery(document).ready(function($) { //first slide down and blink the alert box $("#object").animate({ top: "0px" }, 1000 ).fadeOut(2000); //close the message box when the cross image is clicked $("#close_message").click(function() { $("#object").fadeOut("slow"); }); });