ConfirmIt Netherlands zip code validation

Validate the provided answer using the Netherlands zip code format e.g. 1111BB.

//surveyscripting.com

function PostCode(str)
{
  var result = true;
  var valid = "abcdefghijklmnopqrstuvwxyz";
  var final = '';

  if (str.length > 6)
  {
    result = false;
  }
  else {
    for (var i : int = 0; i < 6; ++i)
    {
      var chstr = str.charAt(i).toLowerCase();
      if (i < 4)
      {		
        if (!IsNumeric(chstr))
        {
          result = false;
          break;
        }
        else {		
          final += chstr;
        }
      }
      if (i >=4 && valid.indexOf(chstr) == -1)
      {
        result = false;
        break;
      }
    }
  }
  if (final < 1000 || result == false)
  {
    RaiseError();
    SetQuestionErrorMessage(CurrentLang(), "Please select a valida zip code!");
  }
}