egorius: (Default)
[personal profile] egorius

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

<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>

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

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

Profile

egorius: (Default)
egorius

July 2025

M T W T F S S
  123456
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 3rd, 2025 04:00 am
Powered by Dreamwidth Studios