JS之经典代码段续二

  1.  /*根据元素ID查找元素*/
  2. function $() {
  3. var elements = new Array();
  4. for (var i = 0; i < arguments.length; i++) {
  5. var element = arguments[i];
  6. if (typeof element == 'string')
  7. element = document.getElementById(element);
  8.     if (arguments.length == 1)
  9. return element;
  10. elements.push(element);
  11.   }
  12.   return elements;
  13. }
  14. /*根据元素ID取得元素*/
  15. function $E(elemid) {
  16. return document.getElementById(elemid);
  17. }
  18. /*根据元素ID取得元素的value*/
  19. function $Vo(elemid) {
  20. return document.getElementById(elemid).value;
  21. }
  22. /*根据元素ID取得元素的innerHTML*/
  23. function $H(elemid) {
  24. return document.getElementById(elemid).innerHTML;
  25. }
  26. /*根据元素ID隐藏该元素*/
  27. function $Hide(id) {
  28.     document.getElementById(id).style.display = 'none';
  29. }
  30. /*根据元素ID显示该元素*/
  31. function $Display(id) {
  32.     document.getElementById(id).style.display = 'block';
  33. }
  34. /*根据元素ID设置该元素为空*/
  35. function $Dlose(id) {
  36.     document.getElementById(id).innerHTML='';
  37. }
  38. /*网页转向*/
  39. function $U(url){
  40. window.location.href=url;
  41. }
  42. /*取字符长度,一个中文字符为两个字节*/
  43. function $Len(str){
  44. return (''+str).replace(/[^/x0000-/xFF00]/gi,'xx').length;
  45. }
  46. //用正则表达式将前后空格用空字符串替代。
  47. function trim(strSrc)
  48. {
  49. return strSrc.replace(/(^/s*)|(/s*$)/g, "");
  50. }
  51. //onkeypress时根据输入类型控制输入字符,"F":浮点型 "I":整型 "D":日期型
  52. function filterKey(sType){
  53. var iKey = window.event.keyCode;
  54. if(sType == "F"){ //浮点型
  55. if(iKey != 45 && iKey != 46 && iKey != 13 && iKey != 11 && !(iKey>=48 && iKey<=57))
  56. window.event.keyCode = 0
  57. else{
  58. if(iKey == 46){
  59. var obj = window.event.srcElement;
  60. if(obj.value.indexOf(".")>=0)
  61. window.event.keyCode = 0;
  62. }
  63. if(iKey == 45){
  64. var obj = window.event.srcElement;
  65. if(obj.value.indexOf("-")>=0)
  66. window.event.keyCode = 0;
  67. else{
  68. window.event.keyCode = 0;
  69. obj.value = "-" + obj.value;
  70. if(obj.onchange != null){
  71. obj.onchange();
  72. }
  73. }
  74. }
  75. }
  76. //end "F"
  77. else if(sType == "I"){ //整型
  78. if(iKey != 13 && iKey != 45 && iKey != 11 && !(iKey>=48 && iKey<=57))
  79. window.event.keyCode = 0;
  80. else if(iKey == 45){
  81. var obj = window.event.srcElement;
  82. if(obj.value.indexOf("-")>=0)
  83. window.event.keyCode = 0;
  84. else{
  85. window.event.keyCode = 0;
  86. obj.value = "-" + obj.value;
  87. if(obj.onchange != null){
  88. obj.onchange();
  89. }
  90. }
  91. }
  92. // end "I"
  93. else if(sType == "D"){ //日期型
  94. var obj = window.event.srcElement;
  95. var strDate = obj.value;
  96. if(strDate.length>=10){
  97. window.event.keyCode = 0;
  98. return;
  99. }
  100. else if(strDate.length<4){ //年
  101. if(iKey != 13 && iKey != 11 && !(iKey>=48 && iKey<=57))
  102. window.event.keyCode = 0;
  103. }
  104. else if(strDate.length == 4){ //分隔符
  105. if(iKey != 45 && iKey != 47)
  106. window.event.keyCode = 0;
  107. }
  108. else if(strDate.length>=5){
  109. if( strDate.indexOf("-") > 0 && strDate.indexOf("-") == strDate.lastIndexOf("-")){ //正输入月份
  110. if(strDate.length>=7 && iKey != 45){ //如果长度过长,则退出
  111. window.event.keyCode = 0;
  112. return;
  113. }
  114. if(iKey>=48 && iKey<=57){
  115. var iPos = strDate.indexOf("-");
  116. var iMonth = parseInt("" + strDate.substr(iPos+1,strDate.length-iPos-1) + (parseInt(iKey) - 48));
  117. if(strDate.length>=6 && (iMonth <1 || iMonth > 12)){
  118. window.event.keyCode = 0;
  119. return;
  120. }
  121. }
  122. // end if("-")
  123. else if( strDate.indexOf("/") > 0 && strDate.indexOf("/") == strDate.lastIndexOf("/")){ //正输入月份
  124. if(strDate.length>=7 && iKey != 47){ //如果长度过长,则退出
  125. window.event.keyCode = 0;
  126. return;
  127. }
  128. if(iKey>=48 && iKey<=57){
  129. var iPos = strDate.indexOf("/");
  130. var iMonth = parseInt("" + strDate.substr(iPos+1,strDate.length-iPos-1) + (parseInt(iKey) - 48));
  131. if(strDate.length >= 6 && (iMonth <1 || iMonth > 12)){
  132. window.event.keyCode = 0;
  133. return;
  134. }
  135. }
  136. // end if("/")
  137. else if( strDate.indexOf("-") > 0 && strDate.indexOf("-") != strDate.lastIndexOf("-")){ //正输入日期
  138. if(iKey>=48 && iKey<=57){
  139. var iPos = strDate.lastIndexOf("-");
  140. if(strDate.length - iPos > 2){
  141. window.event.keyCode = 0;
  142. return;
  143. }
  144. var iDay = parseInt("" + strDate.substr(iPos+1,strDate.length-iPos-1) + (parseInt(iKey) - 48));
  145. if(iDay > 31){
  146. window.event.keyCode = 0;
  147. return;
  148. }
  149. }
  150. }
  151. else if( strDate.indexOf("/") > 0 && strDate.indexOf("/") != strDate.lastIndexOf("/")){ //正输入日期
  152. if(iKey>=48 && iKey<=57){
  153. var iPos = strDate.lastIndexOf("/");
  154. if(strDate.length - iPos > 2){
  155. window.event.keyCode = 0;
  156. return;
  157. }
  158. var iDay = parseInt("" + strDate.substr(iPos+1,strDate.length-iPos-1) + (parseInt(iKey) - 48));
  159. if(iDay > 31){
  160. window.event.keyCode = 0;
  161. return;
  162. }
  163. }
  164. }
  165. }
  166. if(strDate.charAt(strDate.length-1) == "-" || strDate.charAt(strDate.length-1) == "/"){
  167. if(iKey != 13 && iKey != 11 && !(iKey>=48 && iKey<=57))
  168. window.event.keyCode = 0;
  169. }
  170. if(iKey == 47 || iKey == 45){
  171. if(strDate.indexOf("-") > 0 && iKey == 47)
  172. window.event.keyCode = 0;
  173. if(strDate.indexOf("/") > 0 && iKey == 45)
  174. window.event.keyCode = 0;
  175. }
  176. // end "D"
  177. }



  1. /*自适应大小*/
  2. function DrawImage(ImgD,_width,_height){
  3. if(!_width) _width=120;
  4. if(!_height) _height=120;
  5. var flag=false;
  6. var image=new Image();
  7. image.src=ImgD.src;
  8. if(image.width>0&&image.height>0){
  9. flag=true;
  10. if(image.width/image.height>=_width/_height){//120/120
  11. if(image.width>_width){  
  12. ImgD.width=_width;
  13. ImgD.height=(image.height*_width)/image.width;
  14. }else{
  15. ImgD.width=image.width;  
  16. ImgD.height=image.height;
  17. }
  18. ImgD.alt=image.width+"X"+image.height;
  19. }
  20. else{
  21. if(image.height>_height){  
  22. ImgD.height=_height;
  23. ImgD.width=(image.width*_height)/image.height;  
  24. }else{
  25. ImgD.width=image.width;  
  26. ImgD.height=image.height;
  27. }
  28. ImgD.alt=image.width+"X"+image.height;
  29. }
  30. }
  31. /*Cookie*/
  32. function setCookie(name,value)
  33. {
  34.     var Days = 365;
  35.     var exp  = new Date();    //new Date("December 31, 9998");
  36.         exp.setTime(exp.getTime() + Days*24*60*60);
  37.         document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
  38. }
  39. function getCookie(name)
  40. {
  41.     var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
  42. if(arr=document.cookie.match(reg))
  43. return unescape(arr[2]);
  44. else
  45. return null;
  46. }
  47. function delCookie(name)
  48. {
  49.     var exp = new Date();
  50.         exp.setTime(exp.getTime() - 1);
  51.     var cval=getCookie(name);
  52.         if(cval!=null)
  53.         document.cookie= name + "="+cval+";expires="+exp.toGMTString();
  54. }
  55. /*验证数字*/
  56. function isNumber(e){
  57. var number = "1234567890";
  58. for(var i=0; i<e.length; i++){
  59. if (number.indexOf(e.charAt(i))<0) {
  60. return false;
  61. }
  62. }
  63. return true;
  64. }
  65. /*验证数字*/
  66. function isAllDigits(argvalue) {
  67.     argvalue = argvalue.toString();
  68.     var validChars = "0123456789";
  69.     var startFrom = 0;
  70.     if (argvalue.substring(0, 2) == "0x") {
  71.        validChars = "0123456789abcdefABCDEF";
  72.        startFrom = 2;
  73.     } else if (argvalue.charAt(0) == "0") {
  74.        validChars = "01234567";
  75.        startFrom = 1;
  76.     } else if (argvalue.charAt(0) == "-") {
  77.         startFrom = 1;
  78.     }
  79.    
  80.     for (var n = startFrom; n < argvalue.length; n++) {
  81.         if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
  82.     }
  83.     return true;
  84. }
  85. /*检查Email是否合法*/
  86. function isEmail(s){
  87.     if (s.length<7||s.length > 50){
  88.             return false;
  89.     }
  90.      var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$"
  91.      var re = new RegExp(regu);
  92.      if (s.search(re) != -1) {
  93.            return true;
  94.      } else {
  95.            return false;
  96.      }
  97. }
  98. /*检查字符串是否为Null*/
  99. function isNull(s){
  100.     if (s == null || s.length <= 0 || s.trim() == ""){
  101.             return true;
  102.     }
  103.     return false;
  104. }
  105. /*检查字符串是否为空*/
  106. function isEmpty(s){
  107.     if (s == null || s.length <= 0 || s.trim() == ""){
  108.             return true;
  109.     }
  110.     return false;

  1. /*检查日期是否合法*/
  2. function isValidDate(day, month, year) {
  3.     if (month < 1 || month > 12) {
  4.             return false;
  5.         }
  6.         if (day < 1 || day > 31) {
  7.             return false;
  8.         }
  9.         if ((month == 4 || month == 6 || month == 9 || month == 11) &&
  10.             (day == 31)) {
  11.             return false;
  12.         }
  13.         if (month == 2) {
  14.             var leap = (year % 4 == 0 &&
  15.                        (year % 100 != 0 || year % 400 == 0));
  16.             if (day>29 || (day == 29 && !leap)) {
  17.                 return false;
  18.             }
  19.         }
  20.         return true;
  21.     }
  22. /*获得Radio的值*/
  23. function getRadioValue(name){
  24. var radios = document.getElementsByName(name);
  25. var i;  
  26. if (null == radios.length){
  27.   if(radios.checked) {
  28.   return radios.value;
  29.   }
  30. }
  31.     for(i = 0; i < radios.length; i++){
  32.        if(radios[i].checked){
  33.      return radios[i].value;
  34.        }
  35.     }
  36.     return 0;
  37. }
  38. /*设置Radio的值*/
  39. function setRadioValue(name,value){
  40. var radios = document.getElementsByName(name);
  41. var i;
  42. if (null == radios.length){
  43.   if(radios.checked) {
  44.   radios.checked = "checked";
  45.   }
  46. }
  47.     for(i=0;i<radios.length;i++){
  48.        if(value == radios[i].value){
  49.      radios[i].checked = "checked";
  50.        }
  51.     }
  52.     return 0;
  53. }
  54. /*获得CheckBox的值,多个为数组*/
  55. function getCheckBoxValues(name){
  56. var values = new Array();
  57. var cbs = document.getElementsByName(name);
  58. var i;  
  59. if (null == cbs) return values;  
  60. if (null == cbs.length){
  61.   if(cbs.checked) {
  62.   values[values.length] = cbs.value;
  63.   }
  64.   return values;
  65. }    
  66. var count = 0 ; 
  67. for(i = 0; i<cbs.length; i++){
  68. if(cbs[i].checked){
  69. values[values.length] = cbs[i].value;
  70. }
  71. }
  72. return values;
  73. }
  74. /*设置CheckBox的值*/
  75. function setCheckBoxValue(name,value){
  76. var cbs = document.getElementsByName(name);
  77. var i;
  78.     if (null == cbs) return 0 ;
  79.   if (null == cbs.length){
  80.   cbs.checked = value;
  81.   return 0;
  82.   }
  83. for(i=0;i<cbs.length;i++){
  84.   cbs[i].checked = value;
  85.   }
  86.   return 0;
  87. }
  88. /*设置CheckBox选中状态*/
  89. function setCheckBoxs(name,value){
  90. var cbs = document.getElementsByName(name);
  91. var i;
  92.     if (null == cbs) return 0 ;
  93.   if (null == cbs.length){
  94.   cbs.checked = true;
  95.   return 0;
  96.   }
  97. for(i=0;i<cbs.length;i++){
  98. if(cbs[i].value == value){
  99. cbs[i].checked = true;
  100. }
  101.   }
  102.   return 0;
  103. }
  104. function htmlEncode(text) {
  105. return text.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');

  1. var Request = new Object();
  2. Request.send = function(url, method, callback, data, urlencoded) {
  3.     var req;
  4.     if (window.XMLHttpRequest) {
  5.         req = new XMLHttpRequest();
  6.         if (req.overrideMimeType) {
  7. req.overrideMimeType('text/xml');
  8. }
  9.     } else if (window.ActiveXObject) {
  10.         req = new ActiveXObject("Microsoft.XMLHTTP");
  11.     }
  12.     req.onreadystatechange = function() {
  13.         if (req.readyState == 4) {
  14.             if (req.status < 400) {
  15.                 (method=="POST") ? callback(req) : callback(req,data);
  16.             } else {
  17.             }
  18.         }
  19.     }
  20.     if (method=="POST") {
  21.         req.open("POST", url, true);
  22.         if (urlencoded) req.setRequestHeader('Content-Type''application/x-www-form-urlencoded');
  23.         req.send(data);
  24.     } else {
  25.         req.open("GET", url, true);
  26.         req.send(null);
  27.     }
  28.    // return req;
  29. }
  30. Request.sendRawPOST = function(url, data, callback) {
  31.     Request.send(url, "POST", callback, data, false);
  32. }
  33. Request.sendPOST = function(url, data, callback) {
  34.     Request.send(url, "POST", callback, data, true);
  35. }
  36. Request.sendGET = function(url,callback) {
  37.     Request.send(url, "GET", callback, nullnull);
  38. }
  39. /*分析status文件的内容*/
  40. function parseResponseStatus(documentElement){
  41.      var dataobj = new Object();
  42. //parse status
  43. var status = documentElement.getElementsByTagName("status");
  44. if(status && status.length > 0){
  45. if(status[0].firstChild){
  46. dataobj.status = status[0].firstChild.nodeValue;
  47. }
  48. else{
  49. dataobj.status = "";
  50. }
  51. }
  52. return dataobj;
  53. }
  54. //提交form,把得到的数据放在指定的ID上.
  55. function ajaxFormRequest(datastr) {
  56. eval("var obj = "+datastr+";");
  57. if (obj.id == null)
  58.   obj.id = "输入自定义id";
  59.   disableBtn();
  60. dojo.io.bind({
  61. url: parseUrl(obj.url),
  62. useCache: false,
  63. preventCache: false,
  64. encoding:'UTF-8',
  65. load: function(type, data, evt) {
  66. $E(obj.id).innerHTML = data;
  67. enableBtn();
  68. },
  69. error: function(type, error) { alert("error");},
  70. mimetype: "text/plain",
  71. formNode: $E(obj.form)
  72. });
  73. }
  74. //提交form,执行load方法
  75. function ajaxRequestLoad(datastr) {
  76. eval("var obj = "+datastr+";");
  77. if (obj.id == null)
  78.   obj.id = "输入自定义id";
  79.   disableBtn();
  80. dojo.io.bind({
  81. url: parseUrl(obj.url),
  82. useCache: false,
  83. preventCache: false,
  84. encoding:'UTF-8',
  85. load: obj.load,
  86. error: function(type, error) { alert("error");},
  87. mimetype: "text/plain",
  88. formNode: $E(obj.form)
  89. });


  1. /*金额标签转换函数*/
  2. function money_convert(name){
  3. var formatName = name  + "_format";
  4. var strValue = document.getElementById(formatName).value;
  5.     strValue=strValue.replace(",","");
  6.     var regex = /^(0(/./d{0,2})?|([1-9]+[0]*)+(/./d{0,2})?)$/;
  7.     if(!regex.test(strValue)){
  8.     //alert("金额格式不正确!");
  9.     document.getElementById(name).value=0;
  10.     document.getElementById(formatName).value=0;
  11.     }else{
  12.      
  13. strValue = Math.round(parseFloat(strValue)*1000+0.001);
  14.       document.getElementById(name).value=strValue;
  15.     }
  16. }
  17. /*金额标签转换函数
  18. * 获得焦点时,去掉金额中的','符号
  19. */
  20. function prepare(obj){
  21. var strValue = obj.value;
  22. strValue=strValue.replaceAll(",","");
  23. obj.value = strValue;
  24. obj.select();
  25. }
  26. String.prototype.replaceAll  = function(s1,s2){   
  27. return this.replace(new RegExp(s1,"gm"),s2);   
  28. }  
  29. /*日期标签转换函数*/
  30. function setDate(name){
  31. var formatName = "format_" + name;
  32. var tempDate = document.getElementById(name).value;
  33. var validateDate = dojo.widget.byId(formatName).inputNode.value;
  34. var regex = /^[1-9]{1}/d{3}-/d{1,2}-/d{1,2}$/;
  35. if(regex.test(validateDate)){
  36. var dateString = validateDate.split("-");
  37. var year = dateString[0];
  38. var month = dateString[1];
  39. var day = dateString[2];
  40. if(testMonth(month)&&testDay(year,month,day)){
  41. document.getElementById(name).value=validateDate;
  42. return;
  43. }
  44. }
  45. if(validateDate==""){
  46. tempDate="";
  47. }
  48. dojo.widget.byId(formatName).inputNode.value=tempDate;
  49. document.getElementById(name).value=tempDate;
  50. }
  51. function testMonth(month){
  52. if (month < 1 || month > 12)  
  53.     {               
  54.         alert("月份应该为1到12的整数");
  55.         return false;  
  56.     }
  57.     return true;
  58. }
  59. function testDay(year,month,day){
  60.     if (day < 1 || day > 31)  
  61.     {  
  62.         alert("每个月的天数应该为1到31的整数");
  63.         return false;  
  64.     }       
  65.     if ((month==4 || month==6 || month==9 || month==11) && day==31)  
  66.     {  
  67.         alert("该月不存在31号"); 
  68.         return false;  
  69.     }       
  70.     if (month==2)  
  71.     {  
  72.         var isleap=(year % 4==0 && (year % 100 !=0 || year % 400==0));  
  73.         if (day>29)  
  74.         {                 
  75.             alert("2月最多有29天"); 
  76.             return false;  
  77.         }  
  78.         if ((day==29) && (!isleap))  
  79.         {                 
  80.             alert("闰年2月才有29天"); 
  81.             return false;  
  82.         }  
  83.     }  
  84.     return true
  85. }
  86. //比较两个日期是否有效(第一个日期不能在大于第二个日期);第一个日期可以为空,当为空时不进行验证
  87. function compareTwoDate(startDate,endDate,s){
  88. var a=startDate;
  89. var b=endDate;
  90. if(startDate==""){
  91. return true;
  92. }
  93. if(((Number(a.substring(0,4))-Number(b.substring(0,4)))*356+
  94.        (Number(a.substring(5,7))-Number(b.substring(5,7)))*31+
  95.     (Number(a.substring(8,10))-Number(b.substring(8,10))))>0){
  96.   alert(s);
  97.   //startDate.focus();
  98.   return false;
  99. }
  100. return true;
  101. }
  102. //比较两个日期时间是否有效(第一个日期时间不能在大于第二个日期时间);第一个日期时间可以为空,当为空时不进行验证
  103. function compareTwoDateTime(startDate,endDate,startTime,endTime,s){
  104. var a=startDate;
  105. var b=endDate;
  106. var at = startTime;
  107. var bt = endTime;
  108. if(startDate==""){
  109. return true;
  110. }
  111. if(((Number(a.substring(0,4))-Number(b.substring(0,4)))*356*24*3600+
  112.        (Number(a.substring(5,7))-Number(b.substring(5,7)))*31*24*3600+
  113.     (Number(a.substring(8,10))-Number(b.substring(8,10)))*24*3600+
  114.     (Number(at.substring(0,2))-Number(bt.substring(0,2)))*3600+
  115.     (Number(at.substring(3,5))-Number(bt.substring(3,5)))*60+
  116.     (Number(at.substring(6))-Number(bt.substring(6)))>0)){
  117.   alert(s);
  118.   return false;
  119.   //startDate.focus();
  120. }
  121. return true;
  122. }
  123. //验证时间是否合法.
  124. function testTime(time){
  125. var regex = /^[0-2]{1}[0-9]{1}:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/;
  126. if(!regex.test(time)){
  127. alert("您输入的时间格式不正确!");
  128. return false;
  129. }
  130. var hour = time.substring(0,2);
  131. var minute = time.substring(3,5);
  132. var second = time.substring(6);
  133. if(hour>23 || hour <0){
  134. alert("小时的值应该在0-23之间!");
  135. return false;
  136. }
  137. if(minute > 60 ||minute < 0){
  138. alert("分钟的值应该在0-59之间!");
  139. return false;
  140. }
  141. if(second > 60 ||second < 0){
  142. alert("秒钟的值应该在0-59之间!");
  143. return false;
  144. }
  145. return true;
  146. }
  147. String.prototype.trim=function(){
  148.         return this.replace(/(^/s*)|(/s*$)/g, "");
  149. }
  150. function sendmoneycheck(path,orderSeqid) {
  151. var password = document.getElementById('password').value;
  152.         if(document.getElementById('password').value==null || document.getElementById('password').value=='') {
  153. alert('取款密码必须输入');
  154. else {
  155. var url = path+'/sendmoney/managerecconfirmsendmoney.htm?orderSeqid='+orderSeqid+'&passwd='+document.getElementById('password').value;
  156. ajaxFormRequest('{url:"'+url+'",id:"paginationResult"}');
  157. $E('buttonconfirm').disabled=true;
  158. }
  159. }
  160. function isUrlValidate(url){
  161. var regx = /^(/s)*(http(s)?:)?([/w-]+/.)+[/w-]+(:(/d{1,4}))?(//[/w-.//?%&=]*)?(/s)*$/;
  162. return regx.test(url);
  163. }
  164. function isDateValidate(strDate){
  165. var regx = /^([1-2]/d{3})[//|/-](0?[1-9]|10|11|12)[//|/-]([1-2]?[0-9]|0[1-9]|30|31)$/;
  166. return regx.test(strDate);
  167. }
  168. function isEmailValidate(email){
  169. var regx = /^(/s)*([/w]+([-_.][/w]+)*@[/w]+([.][/w]+)*/.[/w]+([.][/w]+)*)(/s)*$/;
  170. return regx.test(email);
  171. }
  172. function isPhoneValidate(tel){
  173. var regx = /^(/s)*((1[35]/d{9})|((0/d{2,3}/-){1}[1-9]{1}/d{6,7}(/-/d{1,4})?))(/s)*$/;
  174. return regx.test(tel);
  175. }
  176. function isMobileValidate(tel){
  177. var regx = /^(/s)*(1[35]/d{9})(/s)*$/;
  178. return regx.test(tel);
  179. }
  180. function dateCompare(date1, date2){
  181. date1 = date1.replace(/-/g, "/");
  182. date2 = date2.replace(/-/g, "/");
  183. try{
  184. return Date.parse(date1) - Date.parse(date2);
  185. }
  186. catch(e){
  187. return 0;
  188. }
  189. }
  190. function respond(obj){
  191. if(window.event.keyCode==13){
  192. obj.onblur();
  193. }
  194. }
  195. function parseUrl(url){
  196. var uniqueKey = new Date();
  197. if(url != null && url.indexOf("?") > 0){
  198. url += "&uniqueKey=" + uniqueKey;
  199. }
  200. else{
  201. url += "?uniqueKey=" + uniqueKey;
  202. }
  203. return url;
  204. }
  205. function disableBtn(){
  206. var oBtns = document.getElementsByName("BTN_QRY");
  207. if(oBtns != null && oBtns.length > 0){
  208. for(var i=0; i<oBtns.length; i++){
  209. oBtns[i].disabled = true;
  210. }
  211. }
  212. }
  213. function enableBtn(){
  214. var oBtns = document.getElementsByName("BTN_QRY");
  215. if(oBtns != null && oBtns.length > 0){
  216. for(var i=0; i<oBtns.length; i++){
  217. oBtns[i].disabled = false;
  218. }
  219. }






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值