Skip to content

Instantly share code, notes, and snippets.

@iL53n
Last active January 31, 2023 14:22
Show Gist options
  • Save iL53n/e142fa688eec24aebe0ca73e14a59b04 to your computer and use it in GitHub Desktop.
Save iL53n/e142fa688eec24aebe0ca73e14a59b04 to your computer and use it in GitHub Desktop.

Revisions

  1. iL53n revised this gist Jan 31, 2023. 1 changed file with 35 additions and 69 deletions.
    104 changes: 35 additions & 69 deletions popup_iban_with_validation.js
    Original file line number Diff line number Diff line change
    @@ -1,69 +1,35 @@
    * {
    margin: 0;
    padding: 0;
    }
    .popup {
    z-index: 100;
    width: 100%;
    height: 100%;
    backdrop-filter: blur(5px);
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    text-align: center;
    .popup__content {
    width: 25%;
    overflow: auto;
    padding: 50px;
    background: white;
    border-radius: 8px;
    box-shadow:
    rgba(0, 0, 0, 0.25) 0px 54px 55px,
    rgba(0, 0, 0, 0.12) 0px -12px 30px,
    rgba(0, 0, 0, 0.12) 0px 4px 6px,
    rgba(0, 0, 0, 0.17) 0px 12px 13px,
    rgba(0, 0, 0, 0.09) 0px -3px 5px;
    color: black;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
    }
    }
    input {
    width: 100%;
    padding: 5px;
    }
    .input-label {
    font-size: 14px;
    float: left;
    }
    .btn-group {
    float: right;
    }
    .btn-popup {
    cursor: pointer;
    outline: 0;
    display: inline-block;
    margin: 2px;
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
    padding: 6px 12px;
    border: 1px solid transparent;
    //font-size: 16px;
    border-radius: .25rem;
    &.submit {
    color: #FFF;
    background-color: #7DAD03;
    border-color: #7DAD03;
    }
    &.reject {
    color: #7DAD03;
    border-color: #E3E3E3;
    }
    }
    $(function() {
    $(".popup").hide();
    $(document).ready(function() {
    $(".popup").fadeIn(500);
    });
    $(".reject").click(function() {
    $(".popup").fadeOut(500);
    });
    $(".iban-input").on("input", function() {
    let val = this.value.replace(/\s/g, "");
    let valChars = val.split("");
    val = "";
    let count = 0;

    for (let i in valChars) {
    if (count < 2) {
    valChars[i] = valChars[i].toUpperCase();
    if (!/^[A-Z]+$/.test(valChars[i])) {
    break;
    }
    } else if (!/^[0-9]+$/.test(valChars[i])) {
    continue;
    }
    val += valChars[i];
    if ((count + 1) % 4 === 0) {
    val += " ";
    } else if (count + 1 === 22) {
    break;
    }
    count++;
    }

    this.value = val.trim();
    });
    });
  2. iL53n created this gist Jan 31, 2023.
    69 changes: 69 additions & 0 deletions popup_iban_with_validation.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,69 @@
    * {
    margin: 0;
    padding: 0;
    }
    .popup {
    z-index: 100;
    width: 100%;
    height: 100%;
    backdrop-filter: blur(5px);
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    text-align: center;
    .popup__content {
    width: 25%;
    overflow: auto;
    padding: 50px;
    background: white;
    border-radius: 8px;
    box-shadow:
    rgba(0, 0, 0, 0.25) 0px 54px 55px,
    rgba(0, 0, 0, 0.12) 0px -12px 30px,
    rgba(0, 0, 0, 0.12) 0px 4px 6px,
    rgba(0, 0, 0, 0.17) 0px 12px 13px,
    rgba(0, 0, 0, 0.09) 0px -3px 5px;
    color: black;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
    }
    }
    input {
    width: 100%;
    padding: 5px;
    }
    .input-label {
    font-size: 14px;
    float: left;
    }
    .btn-group {
    float: right;
    }
    .btn-popup {
    cursor: pointer;
    outline: 0;
    display: inline-block;
    margin: 2px;
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
    padding: 6px 12px;
    border: 1px solid transparent;
    //font-size: 16px;
    border-radius: .25rem;
    &.submit {
    color: #FFF;
    background-color: #7DAD03;
    border-color: #7DAD03;
    }
    &.reject {
    color: #7DAD03;
    border-color: #E3E3E3;
    }
    }