[SOLVED] Help with value.replace() and value.toUpperCase()

Hi all.

There is a project ([PlayCanvas | HTML5 Game Engine]) to which I cannot add functions value.replace() and value.toUpperCase().
I will be glad for any help. (although I think it’s very easy to do)

@Alexei_Dobrynovich Hi, I found this example on the forum.

entry.findByName("Name").element.text = name.toUpperCase();

You should be able to use a var type string and just use the toUpperCase. Also, I have not seen the place you were trying to do this in your code.

As a side note if you are trying to get text input as well. Here is a great tutorial project to have a look at.

https://playcanvas.com/project/1005906/overview/ui-text-input

1 Like

I understand that you need to use the string type var.
For an example of understanding, now I made the saved text (when the page is restarted), it changes the case.
But I need it to change to upper case when entering the string.

It’s okay (if it’s not possible with my example). Because you can change the case when you receive the code.
More interested in using value.replace().

I put in the update function

Input.prototype.update = function(dt) {
    this.updateStyle();
    var updText = this.element.value;
    this.element.value = updText.toUpperCase();
};

Works.
Maybe now I’ll come up with another one with value.replace().
Killed all day and at least got something.

value.replace() also need to be placed in the update function.
The question is how to use them together.

Input.prototype.update = function(dt) {
    this.updateStyle();
    var updText = this.element.value;
    this.element.value = updText.replace(/[^a-z\s]/gi, '');
    
};
Input.prototype.update = function(dt) {
    this.updateStyle();
    var updText = this.element.value;
    updText = updText.replace(/[^a-z\s]/gi, '');
    this.element.value = updText.toUpperCase();
};

I did it. @Tirk182 Thanks for the answer).

And now I wonder how to close the topic of condemnation?

You are welcome. I will mark solved.