1
I have a form with 5 selects
and I’m trying to verify 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 mine IF
becomes 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 DOM itself?