html:
<div class="form-group">
<div class="col-md-offset-2 col-md-10" style="margin-left: 0.666667% !important;">
<b>
@*<input type="submit" value="ADD TO CART" style="background-color:#007DB3; color:#ffffff;" class="btn btn-default Font" />*@
<input type="submit" value="ADD TO CART" style="color:#ffffff;" class="btn btn-default Font" />
</b>
</div>
</div>
--------------------------
CSS:
.btn_bck {
background-color: #007FB5 !important;
color: #ffffff !important;
}
.btn_disable {
background-color: #E0E0E0 !important;
color: #A8A8A8 !important;
}
<div class="form-group">
<div class="col-md-offset-2 col-md-10" style="margin-left: 0.666667% !important;">
<b>
@*<input type="submit" value="ADD TO CART" style="background-color:#007DB3; color:#ffffff;" class="btn btn-default Font" />*@
<input type="submit" value="ADD TO CART" style="color:#ffffff;" class="btn btn-default Font" />
</b>
</div>
</div>
--------------------------
CSS:
.btn_bck {
background-color: #007FB5 !important;
color: #ffffff !important;
}
.btn_disable {
background-color: #E0E0E0 !important;
color: #A8A8A8 !important;
}
----------------------
JQuery:
Disable button initially
//disable
$(document).ready(function () {
$(':input[type="submit"]').prop('disabled', true).addClass("btn_disable");
$('input[type="text"]').keyup(function () {
if ($(this).val() != '') {
$(':input[type="submit"]').prop('disabled', false);
}
});
});
Calling Count service and enable button:
$("#radiogrouptarget input:checkbox").on('click', function () {
$("#divLoader").show();
var $box = $(this);
var accounttype;
var promotiontype;
$("input:checkbox:checked").each(function () {
if ($(this).attr("id") == "chk_Cash" || $(this).attr("id") == "chk_House" || $(this).attr("id") == "chk_CashNHouse") {
accounttype = $(this).val();
}
else if ($(this).attr("id") == "checkboxGeneral" || $(this).attr("id") == "checkboxAce" || $(this).attr("id") == "checkboxLawn" || $(this).attr("id") == "checkboxLawnGdn" || $(this).attr("id") == "checkboxPaint")
promotiontype = $(this).val();
});
if ($box.is(":checked")) {
$("#divLoader").show();
var transactionId = '@TempData["TransactionId"]';
var jsondata = JSON.stringify({
'accountType': accounttype,
'promotiontype': promotiontype
//,
//'transactionId': transactionId
});
$.ajax({
type: 'Post',
url: '/api/TerdataListCount/PostListCount/?accountType=' + accounttype + '&promotiontype=' + promotiontype+'&transactionId=' + transactionId,
dataType: 'json',
contentType: "application/json; charset=utf-8",
//data: jsondata,
//data: { 'accountType': accounttype, 'promotiontype':promotiontype},
success: function (result) {
var obj = jQuery.parseJSON(result);
var countShow = obj.count;
var error = obj.errorMessage;
if (countShow != null || countShow != "") {
$('#countDiv').show();
$('#countDivspace').show();
$("#countDiv").html(" <p>This list will send to approximately " + countShow + " recipients.</p>");
Highlighted are specific for enable Button
$(':input[type="submit"]').prop('disabled', false).removeClass("btn_disable");
$(':input[type="submit"]').prop('disabled', false).addClass("btn_bck");
}
else {
$("#loginModal").modal('show');
$('#erroMessage').html("<p>" + obj.errorMessage + "<p>");
}
$("#divLoader").hide();
},
error: function (data) {
$("#divLoader").hide();
$("#loginModal").modal('show');
}
});
$("#loader").hide();
}
else {
$box.parents("fieldset").find("label.label-check").removeClass('label_bold');
$box.prop("checked", false);
}
});
No comments:
Post a Comment