Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

MID in Sawtooth Script?

Trying to use the following without success.

if ( SSI_Mid("ID_APP"),1,1) == "A" )
{
var strErrorMessage = "Wrong ID";
}


also tried

var first = SSI_Mid("ID_APP",1,1);

if (first NE "A")
{
var strErrorMessage = "The ID you entered in incorrect. Please re-enter your Applicant ID.";
}


 Thoughts anyone?

Thanks!


---FOLLOW UP---

Got the following to work


var ID_A = SSI_GetValue("ID_APP");
var n = ID_A.length;
var f = ID_A.substring(1, 1);

if (f != "A")
{
var strErrorMessage = "The ID you entered in incorrect. Please re-enter your Applicant ID.";
}


but still interested to see if there's an SSI solution :)
asked Jan 21 by Chris Guth Bronze (1,380 points)
edited Jan 21 by Chris Guth
The solution you edited in is how you ought to do it.  There is no SSI_Mid function.  One could potentially be added, but string operations like this usually aren't too tricky with out-of-the-box JavaScript.

A Sawtooth Script (i.e., "[% ... %]") solution would not be possible.  Remember that Sawtooth Script is ran on the server while JavaScript is ran on the client (the respondent's computer).  Because we haven't submitted the page, the server doesn't know what the value of "ID_APP" is yet - the value only exists on the client at this point.  That's the division in labor between these two customization tools: JavaScript lets use read and interact with things on the current page, Sawtooth Script lets me read and modify values on the database from other pages.

Your solution to the original question

Please only use this to answer the original question. Otherwise please use comments.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

To avoid this verification in future, please log in or register.
...