Viewing file: pp_js.js (10.26 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
var jquery = jQuery.noConflict(true);
jquery.extend(jquery.expr[':'], {
focus: function(element) {
return element == document.activeElement;
}
});
jquery(document).ready(function(){
jquery(".preventDf").click(function(event){
event.preventDefault();
});
jquery('#btnClear').click(function(){
jquery('#btnClear').parents('form').find(':text:not(.calendarDateInput),:hidden').attr('value','').end().find('select:not(.calendarDateInput)').children().removeAttr('selected').end().attr('value','');
jquery('div.error').remove();
//alert(jquery('#btnClear').parents('form').find(':text,:hidden').length);
});
jquery('.link').hover(function(){
jquery(this).addClass('hover');
},function(){
jquery(this).removeClass('hover');
});
jquery('.preSubmit').click(function(){
jquery('#s_id').attr('value',jquery(this).next(':hidden').attr('value'));
jquery('#s_id').parents('form').trigger('submit');
});
jquery('input[class^="required"],select.required').blur(function(event){
jquery(this).next('span').children('.error').remove();
if(jquery(this).attr('class') == 'required-thai'){
if(!/^[ก-๙ 0-9 . ( ) / -]+$/.test(this.value)){
jquery(this).next('span.error').append('กรุณาป้อนและควรป้อนเป็นภาษาไทยเท่านั้น ');
return false;
}else{
jquery(this).next('span.error').children('.error').remove();
return true;
}
}else if(jquery(this).attr('class')=='required-eng'){
if(!/^[a-z A-Z 0-9 . ( ) / -]+$/.test(this.value)){
jquery(this).next('span.error').append('กรุณาป้อนและควรป้อนเป็นภาษาอังกฤษเท่านั้น ');
return false;
}else{
jquery(this).next('span.error').children('.error').remove();
return true;
}
}else if(jquery(this).attr('class')=='required-float'){
if(!/^[0-9 .]+$/.test(this.value)){
jquery(this).next('span.error').append('กรุณาป้อนและควรป้อนเป็นตัวเลขเท่านั้น ');
return false;
}else{
jquery(this).next('span.error').children('.error').remove();
return true;
}
}else if(jquery(this).attr('class')=='required-int'){
if(!/^[0-9]+$/.test(this.value)){
jquery(this).next('span.error').append('กรุณาป้อนและควรป้อนเป็นตัวเลขเท่านั้น ');
return false;
}else{
jquery(this).next('span.error').children('.error').remove();
return true;
}
}else{
if(this.value == ''){
jquery(this).next('span.error').append('กรุณาป้อนข้อมูล ');
return false;
}else{
jquery(this).next('span.error').children('.error').remove();
return true;
}
}
});
/* jquery('form.chkBeforeSubmit').submit(function(){
jquery('input[class^="required"]').trigger('blur');
var numError = jquery('div.error',this).length;
if(numError)
return false;
});
*/
jquery('table.table tbody tr').hover(function(){
jquery(this).addClass('trHover');
},function(){
jquery(this).removeClass('trHover');
});
jquery('table.tablePrint').find('td.optCol').remove();
});
function clearAttr(attr){
jquery.each(attr,function(index,value){
jquery("#"+index).attr(value,null);
});
}
function pre_submit(id){
jquery('#s_id').attr('value',id);
jquery('#s_id').parents('form').trigger('submit');
}
function preSubmitAdv(id,frm,action){
var $s_id = jquery('#s_id');
$s_id.attr('value',id);
jquery(frm).children().find(':text').attr('value','').end().find('select').children().removeAttr('selected').end().attr('value','');
// jquery('#btnClear').parents('form').find(':text').attr('value','').end().find('select').children().removeAttr('selected').end().attr('value','');
jquery(frm).unbind();
if(action == "" )
jquery(frm).trigger("submit");
else
jquery(frm).attr('action',action).trigger('submit');
}
function preSubmitMHd(arr,frm,action){
// jquery('#btnClear').parents('form').find(':text').attr('value','').end().find('select').children().removeAttr('selected').end().attr('value','');
// jquery(frm).unbind();
jquery("#"+frm).children().find(":text").val(null).end().find("select").children().attr("selected","");
jquery.each(arr,function(key,value){
if(jquery("#"+key).length == 0)
jquery("#"+frm).append("");
else
jquery("#"+key).attr("value",value);
//alert(key+" have "+jquery("#"+key).length+" value = "+jquery("#"+key).val());
});
if(action == "")
jquery("#"+frm).trigger("submit");
else
jquery("#"+frm).attr("action",action).trigger("submit");
}
function confirmDel(id,frm,action,fnc){
if(confirm("คุณต้องการลบใช่หรือไม11่") == true)
if(fnc == "")
preSubmitAdv(id,frm,action);
else
fnc(id,frm,action);
}
function vprint(){
window.print();
}
function chkDisable(ele,obj){
alert(jquery(obj).val());
jquery(obj).attr("value",true);
if(jquery(ele).attr("disabled")==true){
jquery(ele).attr("disabled",false);
jquery(obj).attr("value",false);
}else{
jquery(ele).attr("disabled",true);
jquery(obj).attr("value",true);
}
}
function popUp(url){
strOption = "scrollbars=yes,left=0,top=0,width=500,height=500";
window.open(url,"",strOption);
}
function clearFrm(frm,txtexcept,opt){
var frmId = "#"+frm;
jquery(frmId+" :input").each(function(index){
if(txtexcept.indexOf(jquery(this).attr("id")) < 0){
switch(this.type){
case "password":
case "text":
case "select-one":
case "textarea":
case "hidden":
jquery(this).val("");
break;
case "checkbox":
case "radio":
this.checked = false;
}
}
});
if(opt != ""){
jquery.each(opt,function(id,tag){
jquery(tag+".#"+id).empty();
});
}
}
/*function sendPost(frmId,value,url){
var html = "";
jquery.each(value,function(index,value){
if(jquery("#"+frmId).find("input:hidden[name='"+index+"']").length == 0)
html += "";
else
jquery("input:hidden[name='"+index+"']").val(value);
temp = index;
});
if (url != '')
jquery("#"+frmId).attr("action",url);
jquery("#"+frmId).append(html).trigger("submit");
}*/
function sendPost(frmId, value, url, target) {
var html = "";
if(url != "")
{
if (jquery("#"+frmId).length > 0) {
jquery("#"+frmId).attr("action",url);
}
else {
jquery("body").append(" ")
}
}
if (target != "") {
jquery("#"+frmId).attr("target",target);
}
if (value != "") {
jquery.each(value,function(index,value){
if(jquery("#"+frmId).find("input:hidden[name='"+index+"']").length == 0)
{
html += "";
}else{
jquery("input:hidden[name='"+index+"']").val(value);
}
temp = index;
});
}
jquery("#"+frmId).append(html).trigger("submit");
}
function setSuccessMsg(msg,flag){
// var jflag = parseInt(flag);
var html = "";
else
html += " class=\"fail\">";
html += msg+" ";
jquery(html).appendTo("body").delay(2000).fadeOut(1000);
}
function isDecimal(ele){//check valid กรอกได้เฉพาะจำนวนทศนิยมที่ไม่ติดลบ
val=document.getElementById(ele).value;
if(val!=""){
if(!(parseFloat(val,10)==(val*1))){
alert("กรอกได้เฉพาะตัวเลขและจุดทศนิยมเท่านั้น !");
document.getElementById(ele).value="";
return false;
}else if((val.indexOf("-")!=-1)){
alert("กรอกได้เฉพาะตัวเลขและจุดทศนิยมเท่านั้น !");
document.getElementById(ele).value="";
return false;
}
}
}
function isNumberic(ele){//เฉพาะจำนวนนับ
val=document.getElementById(ele).value;
if(val!=""){
if(!(parseFloat(val,10)==(val*1))){
alert("กรอกได้เฉพาะตัวเลขเท่านั้น !");
document.getElementById(ele).value="";
return false;
}else if((val.indexOf(".")!=-1) bool(false)
|