Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #104832

    In standard Testbox I found a very usefull feature SelectAllOnFocus in order to select and rewrite everithing without the need to select it.

    However I din’t find the same feature on NumericTextBox and DatePicker.

    For numeric textboxes it would be very usefull in oder to avoid errors.

    Is there something equivalent ?

    Tks

    #104837

    Hi,

    You can select the value on focus, here is an example of that: https://codepen.io/svetoslavjqwidgets/pen/RweqLXW

    Best Regards,
    Svetoslav Borislavov

    Smart UI Team
    https://www.htmlelements.com/

    #108700

    Tks for Your help.

    I know the post is quite old but only now I’d the time to try to implement it.

    I tried with numeric textbox but it doesn’t seem to wotk.

    Here my code.<span style=”background-color: #ffffff; padding: 0px 0px 0px 2px;”><span style=”color: #000000; background-color: #ffffff; font-family: ‘Consolas’; font-size: 10pt; white-space: pre;”><span style=”color: #073642; font-weight: bold;”>function</span> </span></span>

    function numericTextboxInit() {
    console.log(“Entrato”);
    for (let i = 0; i < document.getElementsByTagName(‘smart-numeric-text-box’).length; i++) {
    console.log(“numero ” + i);
    const numericTextbox = document.getElementsByTagName(‘smart-numeric-text-box’)[i];
    numericTextbox.addEventListener(‘focus’, (e) => {
    setTimeout(() => {
    console.log(“Farei”);
    e.target.select()
    })
    });
    }
    }

    You see a loop because I can have more than one numeric textbox.

    On the console I see

    Entrato

    numero 0

    numero 1

    but nothing happen when I set the focus on a smart-numeric-text-box.

    What’s wrong ?

    Tks

    #108703

    Hi,

    You should select the input element of the numeric text box and then invoke the select function.
    Here is an example: https://codepen.io/dkeamcaksoem/pen/RwELxNK

    I hope it helps!

    Best Regards,
    Svetoslav Borislavov

    Smart UI Team
    https://www.htmlelements.com/

    #108705

    I tested Your solution but I’ve a onfocus trigger

    <smart-numeric-text-box id=”e53796681″ input-format=”integer” class=”elemento_testo_valore” value=”0″ name=”e53796681″ required=”” onchange=”mostraAlertMsgOption(this)” onfocus=”on_focus(this)”>

    and this seems to inhibit the solution You proposed.

    How can I solve it ?

    Tks

    #108708

    Hi,

    What do you execute on focus? You can both select everything and also do the other actions
    If I have not understood you correctly, explain again.

    Best Regards,
    Svetoslav Borislavov

    Smart UI Team
    https://www.htmlelements.com/

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.