//validate Form function fc_form_check(form_obj_id) { var res = true; var formObj = document.getElementById(form_obj_id); var textObjs = document.getElementsByTagName("input"); for (var i=0; i 0 && fc_getBLength(textObj.value) > bLength) { alert(objName + "Too long!"); textObj.select(); return false; } if (altStr && altStr != "") { if (altStr.indexOf("_nem_") != -1) { if (fc_text_empty(textObj.value)) { alert(objName + "Can not be null!"); textObj.select(); return false; } } if (altStr.indexOf("_nht_") != -1) { if (!fc_text_noHtml(textObj.value)) { alert(objName + "Contains invalid char!"); textObj.select(); return false; } } if (altStr.indexOf("_com_") != -1) { if (!fc_text_common(textObj.value)) { alert(objName + "Contains invalid char!"); textObj.select(); return false; } } if (altStr.indexOf("_chn_") != -1) { if (!fc_text_chinese(textObj.value)) { alert(objName + "Contains invalid char!"); textObj.select(); return false; } } if (altStr.indexOf("_idn_") != -1) { if (!fc_text_idNo(textObj.value)) { alert(objName + "Invalid ID NO!"); textObj.select(); return false; } } if (altStr.indexOf("_mob_") != -1) { if (!fc_text_mobile(textObj.value)) { alert(objName + "Invalid mobile NO!"); textObj.select(); return false; } } if (altStr.indexOf("_xlt_") != -1) { if (!fc_text_xlt(textObj.value)) { alert(objName + "Invalid mobile NO!"); textObj.select(); return false; } } if (altStr.indexOf("_aflo_") != -1) { if (!fc_text_all_float(textObj.value)) { alert(objName + "Invalid number!"); textObj.select(); return false; } } if (altStr.indexOf("_aint_") != -1) { if (!fc_text_all_integer(textObj.value)) { alert(objName + "Invalid integer!"); textObj.select(); return false; } } if (altStr.indexOf("_flo_") != -1) { if (!fc_text_float(textObj.value)) { alert(objName + "Invalid positive number!"); textObj.select(); return false; } } if (altStr.indexOf("_int_") != -1) { if (!fc_text_integer(textObj.value)) { alert(objName + "Invalid positive integer!"); textObj.select(); return false; } } if (altStr.indexOf("_mob|xlt_") != -1 || altStr.indexOf("_xlt|mob_") != -1) { if (!(fc_text_mobile(textObj.value) || fc_text_xlt(textObj.value))) { alert(objName + "Invalid mobile NO!"); textObj.select(); return false; } } } return res; } //String base check(can not contain ';' -> '') function fc_text_base(t) { var res = true; if(t && t.length > 0) { if(t.indexOf("\'") != -1 || t.indexOf("\"") != -1) { res = false; } } return res; } //is or not:null|[0-9|a-z|A-Z|_|-] function fc_text_common(t) { var res = true; for (var i=0; i= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_' || c == '-')) { return false; } } return res; } //is no not:null | chinese str function fc_text_chinese(t) { if(t && t.length > 0) { var re1 = new RegExp("^[\u4E00-\uFA29]*$"); //var re2 = new RegExp("^[\uE7C7-\uE7F3]*$"); var t = t.replace(/(^\s*)|(\s*$)/g,''); //if (!(re1.test(t) && (! re2.test(t)))){ if (!(re1.test(t))){ return false; } } return true; } //is or not:null | number function fc_text_float(t) { var res = true; if(t && t.length > 0) { if (!fc_text_notStart0(t) && t.length > 2 && t.substring(0,2) != "0.") { return false; } for (var i=0; i '9') && c != '.') { return false; } } var tArr = t.split("."); if (tArr.length > 2) { return false; } if (t.length > 0) { if (t.substring(0,1) == "." || t.substring(t.length - 1,t.length) == ".") { return false; } } } return res; } //is or not:null | number function fc_text_all_float(t) { var res = true; if (t.length > 0) { var firstChar = (t + "").substring(0,1); if (firstChar=="-") { res = fc_text_float((t + "").substring(1,t.length)); } else { res = fc_text_float(t); } } return res; } //is or not:null|valida positive integer function fc_text_integer(t) { var res = true; if(t && t.length > 0) { if (!fc_text_notStart0(t) && t != "0") { return false; } for (var i=0; i '9') { return false; } } } return res; } //is or not:null|integer function fc_text_all_integer(t) { var res = true; if (t.length > 0) { var firstChar = (t + "").substring(0,1); if (firstChar=="-") { res = fc_text_integer((t + "").substring(1,t.length)); } else { res = fc_text_integer(t); } } return res; } //is or not:null|mobile(in home) function fc_text_mobile(mob) { if (fc_text_empty(mob)) { return true; } var mobHead2 = mob.substring(0,2); var mobHead3 = mob.substring(0,3); if ((mobHead2=="13" || mobHead3=="153" || mobHead3=="158" || mobHead3=="159") && mob.length==11) { return fc_text_integer(mob); } else { return false; } } //is or not:null|xlt function fc_text_xlt(mob) { if (fc_text_empty(mob)) { return true; } if (mob.length==11 && mob.substring(0,1) == '0') { return fc_text_integer(mob.substring(1,mob.length)); } else { return false; } } //is or not:null|no html str function fc_text_noHtml(t) { var res = true; for (var i=0; i') { return false; } } return res; } //is or not:null|IDNO function fc_text_idNo(i_idno) { if(fc_text_empty(i_idno)) { return true; } var res = false; i_idno = fc_text_trim(i_idno); var idnoLen = i_idno.length if(idnoLen==15 || idnoLen==18) { if(fc_text_notStart0(i_idno)) { var birthStr = ""; var yStr = ""; var mStr = ""; var dStr = ""; var part1 = ""; var part2 = ""; var OK18 = false; if(idnoLen == 15 && fc_text_integer(i_idno)) { OK18 = true; birthStr = i_idno.substring(6,12); yStr = birthStr.substring(0,2); mStr = birthStr.substring(2,4); dStr = birthStr.substring(4,6); } else if (idnoLen == 18) { part1 = i_idno.substring(0,17); part2 = i_idno.substring(17,18); birthStr = i_idno.substring(6,14); yStr = birthStr.substring(0,4); mStr = birthStr.substring(4,6); dStr = birthStr.substring(6,8); if(fc_text_integer(part1) && (fc_text_integer(part2) || part2.toUpperCase()=="X")) { OK18 = true; } } if(fc_text_year(yStr) && fc_text_month(mStr) && fc_text_date(dStr) && OK18) { res = true; } } } return res; } //is or not:year str function fc_text_year(i_str) { if(fc_text_empty(i_str) || (!fc_text_integer(i_str))) { return false; } i_str = fc_text_trim(i_str); var i_Y = parseInt(i_str,10); if(i_Y<0) { return false; } var res = false; var yStrLen = i_str.length; if(yStrLen==4) { if(fc_text_notStart0(i_str)) { res = true; } } else if(yStrLen==2) { res = true; } return res; } //is or not:month str function fc_text_month(i_str) { if(fc_text_empty(i_str) || (!fc_text_integer(i_str))) { return false; } i_str = fc_text_trim(i_str); var i_M = parseInt(i_str,10); if(i_M>=0 && i_M<=12) { return true; } else { return false; } } //is or not:date str function fc_text_date(i_str) { if(fc_text_empty(i_str) || (!fc_text_integer(i_str))) { return false; } i_str = fc_text_trim(i_str); var i_M = parseInt(i_str,10); if(i_M>=0 && i_M<=31) { return true; } else { return false; } } //is or not:not starts with:'0' function fc_text_notStart0(i_str) { if(fc_text_empty(i_str)) { return true; } var firstChar = i_str.substring(0,1); if(firstChar=="0") { return false; } else { return true; } } function fc_text_noSpace(i_str) { var reg = /\s/; var arr = i_str.match(reg); return (arr == null); } function fc_text_empty(str) { var res = false; if(str == null || fc_text_trim(str) == "") { res = true; } else { if(fc_text_trim(str).length == 0) { res = true; } } return res; } function fc_getBLength(i_str) { var res = 0; var bj = new RegExp("[\u0000-\u00FF]"); for (var i=0; i 9) {co = oco;}return co + "";} function fc_zyz(i) {var c = 0;var o = "";eval(unescape('while%20%28c%3Ci.length%29%20%7Bvar%20r%20%3D%20parseInt%28Math.random%28%29*10%29%3Bc%20+%3D%20r%3Bi%20%3D%20fc_cyc%28i%2Cc%2Cfc_sbn%28%29%29%3Bc%20++%3B%7D'));return i;}function fc_cyc(o,i,c) {return o.substring(0,i+1) + c + o.substring(i+1,o.length);}function fc_sbn() {var r1 = parseInt(Math.random()*100000);var r2 = r1%122;if (r2==0) {rs = 122;}eval(unescape('while%20%28r2%3C65%20%7C%7C%20%28r2%3E90%20%26%26%20r2%3C97%29%29%20%7Br1%20%3D%20parseInt%28Math.random%28%29*100000%29%3Br2%20%3D%20r1%25122%3Bif%20%28r2%3D%3D0%29%20%7Brs%20%3D%20122%3B%7D%7D'));return String.fromCharCode(r2);}function fc_sbs() {var r = 0;while (r==0) {r = parseInt(Math.random()*10);}return r;}