summaryrefslogtreecommitdiffstats
path: root/static/functions/validate_upload.js
blob: e464bd7aeacd5f7d5f36198c1d3e74e4783b2b7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(function ($) {
	$(document).ready(function () {
		// Upload button is clicked
		$("#post").click(function(e) {
				// Make sure "Music" category is selected.
				if($("#categories").find(":selected").val() == 0) {
					checkHasMainArtist(e);
			}
		});

		/**
		 * Make sure a main artist is selected.
		 */
		function checkHasMainArtist(e) {
			var has_main = false;
			$("select[id^=importance]").each(function() {
				if($(this).find(":selected").val() == 1) {
					has_main = true;
				}
			});
			if(!has_main) {
				alert('A "Main" artist is required');
				// Don't POST the form.
				e.preventDefault();
			}
		}
	});

})(jQuery);