validation inside a dialog
Hi,
I have a dialog box that is working fine, the end user has to check one or more checkboxes before pressing the button "Assign", I want to have a validation before submitting, if no checkbox were checked it should diaply an error validation, here is my code :
I would like to check if the array
agenciesId is empty, display an error and don't submit.
- $("#divPopUp").dialog({
- resizable: true,
- autoOpen: false,
- height: 500,
- width: 550,
- modal: true,
- buttons: {
- "Assign": function () {
- var agenciesId = $(this).find(":checkbox:checked").map(function () {
- return this.value;
- }).get();
- //alert("agenciesId :" + agenciesId);
- var ruleIDd = $("#divPopUp").data('param_1');
- $.ajax({
- url: 'assignRenameRuleToAgency.do',
- data: {"agenciesId": agenciesId,"ruleId":ruleIDd },
- success: function(response) {
- toastr.success(response.message);
- oTable.draw(false);
- //oTable.fnStandingRedraw();
- }
- });
- $(this).dialog("close");
- },
- Cancel: function () {
- $(this).dialog("close");
- }
- },
- close: function () {
- $(this).find(":checkbox").removeAttr('checked');
- $(this).dialog("close");
- }
- });
Thanks.