Limit Text Input Box

New Here ,
Mar 07, 2021 Mar 07, 2021

Copy link to clipboard

Copied

Evening everybody.

Small question: is there a way to limit the amount of characters you can write in the TextInput box in Adobe Animate html5 canvas component ?

Thank you for your time.

Views

76

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 07, 2021 Mar 07, 2021

Copy link to clipboard

Copied

for component ti:

 

var max_chars = 2;
if(!this.alreadyExecuted) {
function keyupF(e) {
if (e.target.value.length >= max_chars) {
e.target.value = e.target.value.substr(0, max_chars);
}
}
$("#dom_overlay_container").on("keyup", "#ti", keyupF.bind(this));
this.alreadyExecuted = true;
}

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

Hi kglad,

I had a similar request (max characters) but I would also like to restrict the input to numbers only. I had some luck with:

if(!this.inputNumber_change_cbk) {
function inputNumber_change(evt) {
var regex = /[^0-9]/g;
evt.target.value = evt.target.value.replace(regex, "");
}
$("#dom_overlay_container").on("change", "#timeLength", inputNumber_change.bind(this));
this.inputNumber_change_cbk = true;

}

Trouble is that it only works when the user then clicks in the other text box I have. I cannot rely on the user doing that.

Basically I need it to occur as the user types into the #timeLength field.

Can you please advise?

Regards,

Ron

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 21, 2021 Apr 21, 2021

Copy link to clipboard

Copied

var max_chars = 2;

var regex = /[^0-9]/g;
if(!this.alreadyExecuted) {
function keyupF(e) {
e.target.value = e.target.value.replace(regex, "");
if (e.target.value.length >= max_chars) {
e.target.value = e.target.value.substr(0, max_chars);
}
}
$("#dom_overlay_container").on("keyup", "#ti", keyupF.bind(this));
this.alreadyExecuted = true;
}

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 21, 2021 Apr 21, 2021

Copy link to clipboard

Copied

Thank you so much kglad!

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 21, 2021 Apr 21, 2021

Copy link to clipboard

Copied

you're welcome 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines