Khushbu
Khushbu

Reputation: 205

How to validate a date in textbox, on which calendar is implemented?

I have implemented a jquery calender on asp.net textbox control. When I click on textbox it shows popup calendar, from which a date can be selected.

Now,the issue is I have to validate that the date selected cannot be a past date.
Today's date and date greater than today** are valid.

I have used javascript to call the calendar on the textbox.

I used the code below:

$("#ctl00_ContentPlaceHolder1_txtEventDate").datepicker();

I searched a lot on various websites but not getting any idea.

Note: I have declared script in master page's head and the calendar control is on content page and I do not want page reload.

Upvotes: 1

Views: 1782

Answers (1)

Karthik Chintala
Karthik Chintala

Reputation: 5545

You just need to use minDate option in jquery

<input type="text" id="datep" name="datpicker"/>

<script>
$(document).ready(function(){
    $("#datep").datepicker({
        minDate: 0
    });
});
</script>

Check this fiddle

Upvotes: 1

Related Questions