function validateZipCode(obj) {
    obj.value = trim(obj.value);
    if (isValidZipCode(obj.value)) {
        str = obj.value.replace(/([^0-9.])/g, "");
        obj.value = str.substring(0,3) + " " + str.substring(3);
    }
}

function validatePhoneNumber(obj) {
    obj.value = trim(obj.value);
    if (/^07/.test(obj.value)) {
        str = obj.value.replace(/([^0-9.])/g, "");
        obj.value = str.substring(0,3) + "-" + str.substring(3);
    }
}

function isValidZipCode(str) {
  return str.replace(/([^0-9.])/g, "").length == 5;
}

function trim(str) {
  return str.replace(/^(\s+)?(.*\S)(\s+)?$/, "$2");
}
