Skip to content

Instantly share code, notes, and snippets.

@fyulistian
Created November 14, 2018 04:23
Show Gist options
  • Select an option

  • Save fyulistian/7e99e0bdc12126f8aaeb3d3de18539f6 to your computer and use it in GitHub Desktop.

Select an option

Save fyulistian/7e99e0bdc12126f8aaeb3d3de18539f6 to your computer and use it in GitHub Desktop.
check the similarity between 2 values ​​in the array.
// Set Array
var idAdd = [];
// Push value to array
$('.single-box:checked').map(function () {
var vl = $(this).val();
idAdd.push(vl);
});
// check the array address have same value or not
$chckAdd = idAdd.every((val, i, arr) => val === arr[0]);
// Catch it !!
if ($chckAdd === false) {
swal({
title: "Error",
text: "Tidak boleh berbeda!",
type: "error",
showCancelButton: false,
confirmButtonText: "Ok",
}).then(result => {
if(result.value) $('.check').prop('checked', false);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment