Kichu
Kichu

Reputation: 3267

How to hide the loaded datepicker using jquery

This is my datepicker:

<input type="text" name="offerdate" class="datecls" style="width:62px;" id="date_1" onclick="return check_group_name('date_1');"/>

This is the script:

function check_group_name(dateid) {
        var groupmodelGrpname = $("#groupmodelGrpname").val();
        if(groupmodelGrpname == ""){
            alert("Select Group Before Selecting Offer Date");
            $("#groupmodelGrpname").focus();
            $("#dateid").val("");
            return false;
        }
    }

In my form there have a dropdown box.So I need to check this drop down seleceted before selecting value from datepicker.

That means if i click on datepicker first will check, the drop down have any selected value .If it have not then alert the "Select Group Before Selecting Offer Date".

This is working perfectly ,but there have some issu.

When i clicked on the date picker the alert will come, but the loaded calender not disappearing.

I need to display the calender when there have no alerts means that only alert will come if the drop down have value.

How can i do this?

Upvotes: 1

Views: 3056

Answers (1)

Norbert Pisz
Norbert Pisz

Reputation: 3440

function check_group_name(dateid) {
    var groupmodelGrpname = $("#groupmodelGrpname").val();
    if(groupmodelGrpname == ""){
        alert("Select Group Before Selecting Offer Date");
        $("#groupmodelGrpname").focus();
        $("#dateid").val("");
        $('#dateid').datepicker("hide"); 
        return false;
    }
}

Upvotes: 1

Related Questions