Copy link to clipboard
Copied
I have 6 input texts and a submit button set on visible = false.
When all 6 input texts are filled in the submit button has visible = true. This works fine but I want the button then to get the focus. I can get focus on the input text but I am not sure how to do it with the submit button.
function checkIfDone() {
if (result1.length != 0 && result2.length != 0 && result3.length != 0 && result4.length != 0 && result5.length != 0 && result6.length != 0) {
root.submitBtn3.visible = true;
} else {
root.submitBtn3.visible = false;
}
}
Each input has this code:
function A_change(evt) {
result1 = [];
result1.push(evt.target.value);
// move to next imput field
$("#B").select();
}
// get value
$("#dom_overlay_container").on("change", "#A", A_change.bind(this));
// get submit if all input fields are filled in
$("#dom_overlay_container").on("keyup", "#A", checkIfDone.bind(this));
Copy link to clipboard
Copied
To the best of my knowledge, CreateJS objects do not have the concept of focus.
Copy link to clipboard
Copied
Well, that's too bad. I guess I will try and find some way around.
Copy link to clipboard
Copied
Hi, res.
Yeah. I also agree that there isn't this concept of focus in CreateJS objects.
But if you already using DOM inputs, maybe you could also use a DOM button too. Then you're gonna be able to set the focus, I guess.
Regards,
JC
Copy link to clipboard
Copied
Good idea JC, in general but I am assigned art at work and I cannot change it. I might be able to copy it with CSS tho and definitely worth the try.
Copy link to clipboard
Copied
If the objective is just to submit when Enter is pressed, that's not hard.
var _this = this;
this.submitButton.addEventListener("click", submitClicked);
function submitClicked(evt) {
evt.remove();
window.removeEventListener("keydown", keyPressed);
alert("CLICKED!");
}
window.addEventListener("keydown", keyPressed);
function keyPressed(evt) {
if (evt.key.toLowerCase() === "enter") {
_this.submitButton.dispatchEvent(new createjs.Event("click"));
}
}
Copy link to clipboard
Copied
Thanks Clay
I have 6 input texts. The submit button should appear only when the 6 answers are filled in.
As far as checking the answers all is well. The problem I currently have is how to control the submit button whether it is visible or not.
I need to remove the submit button if the user deletes an answer and keeps it blank and then the button would be visible again if they fill in that blank answer since it would make 6 again.
Hope this makes sense.
PS right now even tho the input that are emptied of an answer do show as empty in the console, the new value is not read by the function for some reason. I wonder why.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Well I ended using this and now it works just fine.
function checkHowMany() {
if($(".A")[0].value != "" && $(".B")[0].value != "" && $(".C")[0].value != "" && $(".D")[0].value != "" && $(".E")[0].value != "" && $(".F")[0].value != "") {
root.submitBtn3.visible = true;
} else {
root.submitBtn3.visible = false;
}
}