Its my HTML code for a image that is link to the another page.
<a href="#" class="dead_prfile_step_next ADInNext">
<img alt="next" src="/Content/DesignFiles/@Html.R(VirtualPath, "dead_profile_free_buttons_next.png")" />
</a>
This is my jquery function for going to next page there is a DDL for months. In that DDL if user selects the previous month than this image link should not work. Otherwise i should work, i know here must be implement a if condition but how can i disable the link for a specific conditions?
$('.ADInNext').click(function () {
if (window.location.href.indexOf("en-US") > -1) {
$('.txtDatePicker').datepicker({
dateFormat: 'mm/dd/yy',
minDate: 0,
onSelect: function (dateText) {
var ddlSelectedPaper = $('#addNewspaperGroup_1 .ddlclassNewpaper option:selected').val();
checkPaperAvailability(dateText, ddlSelectedPaper, 1);
}
});
}
else {
$('.txtDatePicker').datepicker({
dateFormat: 'dd/mm/yy',
minDate: 0,
onSelect: function (dateText) {
var ddlSelectedPaper = $('#addNewspaperGroup_1 .ddlclassNewpaper option:selected').val();
checkPaperAvailability(dateText, ddlSelectedPaper, 1);
}
});
}
$('.ui-helper-hidden-accessible').css('left', '0px');
var OtherOpeningLine = $.trim($("#OtherOpeningLine").val());
var OtherSigned = $.trim($("#OtherSigned").val());
var OtherShiva = $.trim($("#OtherShiva").val())
var OtherSecondline = $.trim($("#OtherSecondLine").val())
if ($("#OpeningLine option:selected").val() == "") {
$("#lblOpeningLine").html('@Html.R(VirtualPath, "Select Opening Line")');
return false;
}
if ('@AdType' == "Obituary") {
if ($("#SecondLine option:selected").val() == "") {
$("#lblSecondLine").html('@Html.R(VirtualPath, "Select Second Line")');
return false;
}
if ($("#SecondLine option:selected").val() == "0") {
if (OtherSecondline == "") {
$("#lblSecondLine").html('@Html.R(VirtualPath, "Select Opening Line")');
return false;
}
}
}
if ($("#Signed option:selected").val() == "") {
$("#lblSigned").html('@Html.R(VirtualPath, "Select Signed")');
return false;
}
if ($("#OpeningLine option:selected").val() == "0") {
if (OtherOpeningLine == "") {
$("#lblOpeningLine").html('@Html.R(VirtualPath, "Select Opening Line")');
return false;
}
}
//To validate if Funeral date is less than current date.
ValidatefuneralDate()
if ($("#Signed option:selected").val() == "0") {
if (OtherSigned == "") {
$("#lblSigned").html('@Html.R(VirtualPath, "Select Signed")');
return false;
}
}
if ($("#Shiva option:selected").val() == "0") {
if (OtherShiva == "") {
$("#lblShiva").html('@Html.R(VirtualPath, "ShivaRequired")');
return false;
}
}
var valid = true;
$('.tab1 input').each(function (index) {
if ($(this).valid() == 0) valid = false;
});
if (valid == true) {
$('.dead_prfile_tab ').addClass("dn");
$('.tab2').removeClass("dn");
return false;
}
else return false;
});
You can try this based on your conditions.
$('.ADInNext').click(function (e) {
e.preventDefault();
});