乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      2013/02/06用MM/MM/MMMM替換

       zww_blog 2013-11-07

      function pageLoad(sender, args) {
       $(document).ready(function() {
        init();
       });
      }

      function init(){
              //Text box Client ID
       SetInputValidationCustom("RadGridProductSuppliers_ctl00_ctl02_ctl02_CostDueDate", /[0-9]/, /^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/, "DD/MM/YYYY", 10);
      }


      //Set Custom Text Field input validation
      function SetInputValidationCustom(ControlID, Regex, Format, FormatValue, Maxlength, ValidatorID) {
       if ($("#" + ControlID + ':enabled').length != 0) {
        var $control = $("#" + ControlID);
        var defaultColor = $control.css("color");
        if (FormatValue != null) {
         $control.focus(function() {
          if ($(this).val().length == 0) {
           $(this).css("color", "#999999");
           $(this).val(FormatValue);
          }
         });
         $control.blur(function() {
          var returnVal = checkDateFormat($(this).val());
          if (returnVal == true) {
           $(this).css("color", defaultColor);
          } else {
           var $this = $(this);
           $this.next("span").remove();
           $this.after('<span style="color:red;position:absolute;display:block;background-color:white;border:1px solid gray;padding:3px;width:' + ($(this).width() - 2 )+ 'px;">Invalida date!</span>');
           $(this).val("");
           setTimeout(function() {
            $this.next("span").animate(
             { opacity: 0 },
             2000,
             function() {
              $this.next("span").remove();
             });
           }, 2000);
          }
         });
        }


        $control.keydown(function(evt) {
         var theEvent = evt || window.event;
         var key = theEvent.keyCode || theEvent.which;
         var position = getCaretPosition(this);
         var value = $(this).val();
         if (theEvent.preventDefault)
          theEvent.preventDefault();

         if (key == 8) {
          if (position == 6 || position == 3)
           $(this).val(value.substring(0, position - 2) + FormatValue.substring(position - 2, position - 1) + value.substring(position - 1));
          else
           $(this).val(value.substring(0, position - 1) + FormatValue.substring(position - 1, position) + value.substring(position));
          setCaretPosition(this, position - 1);
          position = position - 1
          theEvent.returnValue = false;
         } else if (key == 37) {
          setCaretPosition(this, position - 1);
          position = position - 1
          theEvent.returnValue = false;
         } else if (key == 39) {
          setCaretPosition(this, position + 1);
          position = position + 1
          theEvent.returnValue = false;
         } else {
          if (key >= 96 && key <= 105) {
           key -= 48
          }
          character = String.fromCharCode(key);

          if (!Regex.test(character)) {
           theEvent.returnValue = false;
          } else {
           if (Maxlength != null && position >= Maxlength) {
            theEvent.returnValue = false;
           } else {
            $(this).css("color", defaultColor);
            theEvent.returnValue = true;
           }

           if (theEvent.returnValue && (!(position == 2 || position == 5))) {
            var value = $(this).val();

            $(this).val(value.substring(0, position) + character + value.substring(position + 1));
            setCaretPosition(this, position + 1);
            position = position + 1;
           }
          }
         }

         if (position == 2 || position == 5) {
          if (key == 37 || key == 8)
           setCaretPosition(this, position - 1);
          else
           setCaretPosition(this, position + 1);
         }
         if ($(this).val() == FormatValue) {
          $(this).css("color", "#999999");
         }
        });

        $control.click(function() {
         var position = getCaretPosition(this);
         if (position == 2 || position == 5)
          setCaretPosition(this, position + 1);
        })
       }
      }

       

      //Set text field cursor position
      function setCaretPosition(ctrl, pos) {
          if (ctrl.setSelectionRange) {
              ctrl.focus();
              ctrl.setSelectionRange(pos, pos);
          }
          else if (ctrl.createTextRange) {
              var range = ctrl.createTextRange();
              range.collapse(true);
              range.moveEnd('character', pos);
              range.moveStart('character', pos);
              range.select();
          }
      }

      //Get text field cursor position
      function getCaretPosition(ctrl) {
          var CaretPos = 0; // IE Support
          if (document.selection) {
              ctrl.focus();
              var Sel = document.selection.createRange();
              Sel.moveStart('character', -ctrl.value.length);
              CaretPos = Sel.text.length;
          }
          // Firefox support
          else if (ctrl.selectionStart || ctrl.selectionStart == '0')
              CaretPos = ctrl.selectionStart;
          return (CaretPos);
      }

       

      function checkDateFormat(val) {
          var n = val.split("/");
          n[0] = parseInt(n[0]);
          n[1] = parseInt(n[1])
          n[2] = parseInt(n[2])

          if (n[0] < 1 || n[0] > 31) {
              return "There is no date as " + n[0]+"!";
          }
          if (n[1] < 1 || n[1] > 12) {
              return "There is no month as " + n[1] + "!";
          }
         
          if (n[2] < 1) {
              return "There is no year as " + n[2] + "!";
          }

          if (n[0] == 31) {
              var month = [2, 4, 6, 9, 11];
              for (var m in month) {
                  if (n[1] === month[m]) {
                      return "There is no " + n[0] + " in " + (new Date(n[1] + "/01/2012") + "").substring(7, 4) + " " + n[2] + "!";
                  }
              }
          }

          if (n[1] == 2) {
              if (n[2] % 4 == 0) {
                  if (n[0] < 1 || n[0] > 29) {
                      return "There is no " + n[0] + " in " + (new Date(n[1] + "/01/2012") + "").substring(7, 4) + " " + n[2] + "!";
                  }
              } else {
                  if (n[0] < 1 || n[0] > 28) {
                      return "There is no " + n[0] + " in " + (new Date(n[1] + "/01/2012") + "").substring(7, 4) + " " + n[2] + "!";
                  }
              }
          }

          return true;
      }

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶(hù) 評(píng)論公約