Millisecond Forums

Required=false not working for one question

https://forums.millisecond.com/Topic19094.aspx

By jeff.smith - 5/13/2016

Hello,

"/ required = false" is not working for the attached script. I MUST put in a value for the first of 2 questions, but I can leave the second blank.

Ideas?

Jeff
By Dave - 5/13/2016

The specified /range creates an implicit response requirement (it implements a regular expression under the hood). Since that regex doesn't match the empty string, you can't move past the 1st instance of the <openended> without providing a response within the specified range. That effect then carries over to the 2nd instance (although it arguably shouldn't), which allows you to leave the 2nd response blank.

At any rate, the best way to go about this would be to explicitly specify a regex via /mask that matches either the empty string "" or an integer value between 0 and 100 (inclusive):

<openended HHpercent>
/ required=false
/ stimulusframes = [1=HHpercent]
/ mouse=false
/ position= (50, 50)
/ mask = (^$)|^(100|[1-9]?[0-9])$
/ numlines = 1
/ linelength = 4
/ buttonlabel = "Press ENTER to Continue"
</openended>

That should cover all the cases and allow for blank responses in both.
By jeff.smith - 5/13/2016

Very cool :D Thanks, Dave!

Bonus: This solved another problem I was having for a textbox element as well that I wanted to restrict to either leaving blank or integers between 0 and 75.

Also just to note in the help file under mask attribute the following link requires a login:

"For example, see http://utilitymill.com/utility/Regex_For_Range for a tool that generates expressions constraining input to a range of integer values."