How can I check a group of hidden fields for their values and if there are dissimilarities in their values, I will return false. But empty values and “False” should be treated as equal. There are 3 possible values only, empty, True and False but I want to treat empty as False.
I want something like
var isTrue = true;
// is there a way to do this in jquery or similar to this?
var values = $("#group input:hidden").distinct().take(2);
if(values.length == 2) {
// only make it false if there is a true in the values.
if(values[0] == 'True' || values[1] == 'True') {
isTrue = false;
}
}
output should be like
{values[0] = '', values[1] = 'False'} = true
{values[0] = 'True', values[1] = 'False'} = false
{values[0] = '', values[1] = 'True'} = false
Index in the index can be interchanged.
Try adding the following jQuery extension to your code.
Now you should be able to call
$('your-selector-here').haveSameValue()which will return booleantrueorfalsedepending on if all the elements matched (by'your-selector-here') have the same value or not.