Created
November 14, 2018 04:23
-
-
Save fyulistian/7e99e0bdc12126f8aaeb3d3de18539f6 to your computer and use it in GitHub Desktop.
check the similarity between 2 values in the array.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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