Hi friends
I´m creating a dialog and one of the fields in this dialog should accept only numbers. So I thought I could use a combination of Regex and onChanging function with the edittex. Here´s the concept:
var dlg = new Window ("dialog", "Test", undefined);
var txt = dlg.add ("edittext", undefined, "");
txt.characters = 40;
txt.onChanging = function (){
txt.text = txt.text.replace(/[^0123456789]/g, "");
};
dlg.show();
With this code (it´s working) I´m sure user will not be able to type letters or anything else than numbers. But the problem is: if the user hits a letter in keyboard, then, after removing correctlly the letter, the function automatically inserts the pointer of the text in the beginning of such field..So, the next key user presses, it will be inserted in the beginning of the string. And it´s a problem when inserting the text.
Is there any alternative (not necessary needs a regex) I could insert in the onChanging function, so the pointer of text always keep in the end of the field?
If my explanation and question was confused, please tell I try to explain again
Best Regards
Gustavo.