• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to hide submit button in TEB and show when user enter their response?

New Here ,
Apr 28, 2021 Apr 28, 2021

Copy link to clipboard

Copied

I want the user to enter their response in the text entry box (for an open-ended question) and till then the submit button to be hidden/disabled. The submit would be shown only when the TEB has some inputs. I am struck with this. I tried to drag the TEB submit button off the frame and created a new button as submit button and worked with advanced actions but nothing worked. Is there any workaround for this?

 

To give a simple example. I need the user to enter their names in TEB in the first slide which I could use in the rest of the slide with the help of variables. But the submit button should appear only after the user enters any input. We can use auto-submit option only if the number of characters are defined, but we can't limit the number of characters as it is a name.

Any workaround please?

Views

72

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
Community Expert ,
Apr 28, 2021 Apr 28, 2021

Copy link to clipboard

Copied

You don't need to show the Submit button, there is an option to take it out. In that case you can choose a shortcut key. This is just an answer to your initial question, but may I ask you to look out of the box? Your real question to me is: how can I avoid that the Submit button is clicked and the Text Entry Box remains empty, what would lead to an empty value for the associated TEB-variable. Correct or not?

Have a look at this blog post, which explains exactly how to avoid this:

http://blog.lilybiri.com/where-is-null-in-cp2017

 

BTW this  is a non-validated TEB, you can also consider replacing it by a Scrolling Text interaction, which can have an associated variable as well. It may avoid you some pitfalls which are linked with a TEB. I will not overwhelm you with more links. 

Votes

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
Community Expert ,
Apr 28, 2021 Apr 28, 2021

Copy link to clipboard

Copied

I think you may be looking at this the wrong way.  You don't need to use the TEB validation.  You are correct that the normal TEB validation is not going to be suitable for your requirement because there is no option that evaluates to a correc answer if any text entry at all is made.

 

However, if I understand your requirement, what you are really trying to do is make sure the learner enters something into the TEB field before they should be allowed to continue further into the lesson.  Is that correct?

 

If so, then replace the TEB's Submit button (as you were suggesting) and have the replacement button execute a Conditional Advanced actions that checks whether the user has entered a value by simply checking that the value currently stored in the TEB's associated User Variable is not equal to the value of another User Variable that has no value (essentially a null value).  

 

If the user hasn't entered anything, and the conditional evaluates to False, then show a hidden caption or some other kind of warning message that instructs the user they MUST enter a value in the field.  Make sure there is no way the user can navigate further into the module and bypass this conditional entry.  That means disabling the TOC, hiding the Playbar etc.

 

Is there any reason why this approach would not achieve your desired outcome of making sure the user specifies something? 

 

There's still no way to ensure they enter their correct name though.  They could put anything in that TEB field and as long as it's something other than null then they would get in.  This is just another one of those situations where it's actually futile to try and force adult learners to do things against their will.

Votes

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
Advisor ,
Apr 28, 2021 Apr 28, 2021

Copy link to clipboard

Copied

LATEST

Here is a little JavaScript that can help with this.

In this example, my TEB is associated with a variable called  myVar

Delete the default submit button and make your own.

In this example - the button is named  mySubmit. 

Set the button to be hidden by default.

 

The script below will listen for when that variable associated with the TEB changes.

By default it will be empty so when a character is entered, the submit button will show.

Also, if the user deletes all the characters so that it is blank again - the submit button will hide.

This is placed as an  Execute JavaScript  for the onEnter action to the slide.

 

window.cpAPIEventEmitter.addEventListener("CPAPI_VARIABLEVALUECHANGED",function() {
if (myVar!="") {
cp.show("mySubmit");
}
else {
cp.hide("mySubmit");
}
},"myVar");

 

 

Votes

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
Resources
Help resources