Skip to main content
CodeDeveloperOM
Inspiring
January 6, 2021
Answered

Enter numbers only ??

  • January 6, 2021
  • 3 replies
  • 708 views

Want to enter numbers only without letters?

 

++++++++++++++++++

 

setTimeout(function () {
textinputtitle.restrict = "0-9" + "٠-٩";
dom_overlay_container.children["textinputtitle"].maxLength = 1;
what_change();
}, 0);

 

==================

    This topic has been closed for replies.
    Correct answer kglad

    if (!this.exectedOnce) {
    function inputF(e) {
    if (this.num == "invalid") {
    document.getElementById("textinputtitle").value = document.getElementById("textinputtitle").value.slice(0, -1)
    }
    }
    function keyupF(e) {
    if (!isNaN(e.key)) {
    this.num = e.key;
    } else {
    this.num = "invalid";
    }
    }
    $("#dom_overlay_container").on("input", "#textinputtitle", inputF.bind(this));
    $("#dom_overlay_container").on("keydown", "#textinputtitle", keyupF.bind(this));
    this.executedOnce = true;
    }

    3 replies

    CodeDeveloperOM
    Inspiring
    January 14, 2021

    ?? 

    setTimeout(function () {
    var textinputtitle = /[^0-9]/g;
    dom_overlay_container.children["textinputtitle"].maxLength = 1;
    what_change();
    }, 0);

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    January 14, 2021

    if (!this.exectedOnce) {
    function inputF(e) {
    if (this.num == "invalid") {
    document.getElementById("textinputtitle").value = document.getElementById("textinputtitle").value.slice(0, -1)
    }
    }
    function keyupF(e) {
    if (!isNaN(e.key)) {
    this.num = e.key;
    } else {
    this.num = "invalid";
    }
    }
    $("#dom_overlay_container").on("input", "#textinputtitle", inputF.bind(this));
    $("#dom_overlay_container").on("keydown", "#textinputtitle", keyupF.bind(this));
    this.executedOnce = true;
    }

    CodeDeveloperOM
    Inspiring
    January 17, 2021

    Thank you very much for your kind response (^_^) , genius ...
    I wish you always happiness and ease in all your affairs .

    Thanks .

    CodeDeveloperOM
    Inspiring
    January 11, 2021

    ??

    kglad
    Community Expert
    Community Expert
    January 6, 2021

    why do you persist in using a textinput component?

    CodeDeveloperOM
    Inspiring
    January 11, 2021

    Because I want the user to enter a number only ??