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

Text Entry Box Validation Using JavaScript

New Here ,
Aug 05, 2016 Aug 05, 2016

Hi there,

I am developing a course with a TON of text entry validation. I've seen Lilybiri's post on multiple TEB's; one submit button, but the development time is longer than I would like (it works perfectly though- thanks for all you do for us noobs, Lieve!). I was investigating Jim's TEB validation widget, but it's been discontinued (emailed him to see if I can get a license).

Is there a way to use javascript to validate multiple TEB's without this widget and a ton of programming knowledge? I'm working in Captivate 8.

In essence, what I'm thinking is this:
1) Multiple TEB's for email addresses, dates etc. on the canvas.

2) User input is stored in a variable, one for each TEB.

3) the user input is validated against a regular expression

4) a. Captivate provides correct/ incorrect feedback for all of the available text entry fields (using text caption, alert window, or by showing an image of a red X for incorrect) of the data entry that doesn't match the RegEx.

Thank you!

906
Translate
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
LEGEND ,
Aug 06, 2016 Aug 06, 2016

Thanks for the comment on that very old blog post. Of course, JS should be a better way in many use cases than advanced actions and with the new common JS API (for both SWF and HTML output) lot more is possible for that alternative work flow.

If I had more time, should have to upgrade a lot of posts. Shared actions have appeared meanwhile and the amazing CpExtra widget by InfoSemantics. It take quite a lot of time to explore alternatives, and rewrite posts and most present users prefer simple video (mostly very limited, and no explanation) over my more elaborate, in-depth blog posts. Why should I spend so much of my free time to write? Lack of appreciation is killing my energy.

Translate
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 ,
Aug 08, 2016 Aug 08, 2016

lieve- I always appreciate you! On a side note, does the CPExtra Widget handle multiple TEB's, similar to Jim's old widget? 

In case someone runs across my thread with the javascript skills, here is the gist of what I was thinking. I'm starting with just trying to write the code for one text box to validate an email. I've only spent one weekend trying to learn javascript, so I'm sure this is clunky:

var emailAddress = window.cpAPIInterface.getVariableValue
("testBox1"); //Grabs results of the variable “testBox1” from user input

var pattern = window.cpAPIInterface.getVariableValue("regexPattern"); /* I have a regEx pattern stored in a
variable  \b[\w\.-]+@[\w\.-]+\.\w{2,4}\b I assume the regex is correct */

var res = pattern.test(emailAddress); // I believe this tests the regex pattern against the email address

if (res === true) //condition

{window.cpAPIInterface.setVariableValue("emailCorrect",0); //assign “emailCorrect” (captivate variable) with 0 for adv. action.

}

else

{window.cpAPIInterface.setVariableValue ("testName" , "false"); // I just did this for testing purposes to see if it would evaluate

}

Translate
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
LEGEND ,
Aug 08, 2016 Aug 08, 2016
LATEST

I don't remember how Jim's widget worked exactly, but CpExtra has the possibility to address multiple objects at once with the @ or # syntax. Moreover you can call an advanced action from another action (or mix shared and advanced). Those two functionalities combined. Wished I had more time, shouldn't spend so much time on these forums and in groups/twitter.

Translate
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