I have a form with 5 selects
and I'm trying to check if any of these selects are of the same value.
$('form').submit(function (event) {
var $commitment = $("[name='commitment']").val();
var $proActivity = $("[name='proActivity']").val();
var $superation = $("[name='superation']").val();
var $teamWork = $("[name='teamWork']").val();
var $planningAndOrganization = $("[name='planningAndOrganization']").val();
Object.prototype.in = function () {
for (var i = 0; i < arguments.length; i++)
if (arguments[i] == this) return true;
return false;
}
But when I need to validate my IF
gets gigantic;
if ($commitment.in($proActivity, $superation, $teamWork, $planningAndOrganization) ||
$proActivity.in($commitment, $superation, $teamWork, $planningAndOrganization) ||
$superation.in($commitment, $proActivity, $teamWork, $planningAndOrganization) ||
$teamWork.in($commitment, $proActivity, $superation, $planningAndOrganization) ||
$planningAndOrganization.in($commitment, $proActivity, $superation, $teamWork)) {
$('.alert').show();
return false;
}
Is there any way to do this check using the form's own DOM?