TextEntry validation

Feb 26, 2014

How do I validate a text entry box when the field is required. The learner must complete a couple fields, some mandatory before clicking the next click action. On that click action, I want to validate that there is something in the field. Sometimes, I have to validate that it is an email address. All assistance is appreciated.



6 Replies
Michael Hinze

See attached a quick example with two text entry boxes and here is the published version:http://dev.keypointlearn.com/xcl71_SL/TEBContains/V4/story.html.

The first text entry box is checked whether or not it is empty. This is done with a simple 'not equal to (blank)' trigger. The email validation requires a JavaScript that checks if the entered string contains a "@" and a "." character. Hope that helps.

Milton Edwards

Hi Michael, I could use help with the email validation for this Sign-In page. I want to validate the email address, as you did in your example, and I've tweaked with JavaScript, but I'm stuck. My code sample is below this form, but it's not working after I publish and test it in IE. The email textEntry field is called LrnrEmail.

Form

function validateForm()
var x = document.forms["thisForm"]["LrnrEmail"].value;
var atpos = x.indexOf("@");
var dotpos = x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
alert("Not a valid email address.");
return false;

<form name="thisForm" action="demo_form.asp" onsubmit="return" validateForm();" method="post">
<input type="text" name="LrnrEmail">
<input type="submit" value="Next">

I modified code from w3cschool and inserted this version into an Execute JavaScript trigger with the intent of validating the email address after the control loses focus and before the Learner clicks the Next button to advance to the quiz pages.

Would you mind sharing your JavaScript code as an example?

Thanks, in advance, for your help!

Christie Pollick

Hi, Milton -- Thanks for reaching out! As this discussion is dated and the last activity was a few years ago, it's possible that Michael is no longer subscribed to the post. As JavaScript is not something for which we can offer support, if you find that you have specific questions for Michael, you are welcome to reach out via the 'Contact Me' link on his profile page.

This discussion is closed. You can start a new discussion or contact Articulate Support.