How do I validate or make a selection required?

I have a block that has several stripes. I want to be able to tell if a user has selected at least one stripe and which specific stripe. Also, I want to make it so that the user can’t proceed to the next view or action without first selecting a stripe.

How do I make a validation or in this case stripe selection required?

At some point, I will have to save this selection inside my database connected to my web application.

I’m not sure quite of the context of what you call ‘stripes’ however you could store the number of stripes selected in an integer variable. And then only allow the user to proceed if that integer is > 0. pseudo code to follow:

var stripes : int = 0
function stripeSelected(){
	stripes ++;
}

function proceed(){
	if(stripes > 0){
		//allow user to proceed
	}else{
		print('blah stripe is required');
	}
}

Scribe

I think you will need a boolean for each stripe eg. isSelected

Set it to true if it’s clicked.

In the update section for a stripe you could then write:

if (isSelected) {
    //Store stripeID somewhere
    //Give opportunity to next view
}

I’m guessing each stripe is a child of the block object?