egorius: (Default)
egorius ([personal profile] egorius) wrote2005-01-18 04:09 pm

Microsoft®

Нет, други мои, не удержусь. Вот вам проверка из предыдущего поста. Такую красоту нельзя прятать, любуйтесь все:

<script language='javascript'>
  function validatePhone_contactPhoneNumber(oSrc){
    // if number is greater than 10 digits,
    // allow any digits, dashes and '+' at the beginning,
    // must have at least one dash.
    // this is what we are using for intl entry.

    var regx = new RegExp(/^\d+$/);
    var ndigitCount = 0;
    var strValue = document.all.contactPhoneNumber.value;
    var valueWithSpacesRemoved = '';
    // make sure all characters are either digits, dashes, periods, or '+'
    for (var i = 0;  i < strValue.length;  i++) {
      if (regx.test(strValue.charAt(i))) {
        ndigitCount++;
        continue;
      }
      if (strValue.charAt(i) == '-') {
        continue;
      }
      if (strValue.charAt(i) == ' ') {
        continue;
      }
      if (strValue.charAt(i) == '.') {
        continue;
      }
      return false;
    }
    //must have at least 4 digits
    if(ndigitCount < 2){
      return false;
    }

    return true;
  }
</script>

Предлагаю конкурс — кто найдёт больше несоответствий кода и комментариев…


Post a comment in response:

If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting