Jquery validation for date less than today

var isAlreadySubmitted = false;
$(function () {
$(‘#RequisitionDate’).datepicker();
$(“#RequisitionDate”).datepicker(“option”, “dateFormat”, “M d, yy”)

});

the above script will gives up todays date

$(document).ready(function () {
selectTab();
generateValidator($(“#frmOrn”));
$(“#OrderRequisitionNoteTypeName”).rules(‘add’, { isNotEmptyGuid: [“#OrderRequisitionNoteType”, “Order Requisition Note Type”] });
$(“#RequisitionDate”).rules(‘add’, { lessThanOrEqualToCurrentDate: [new Date().toDateString(), “Requisition Date must be less than or equal to today.”] });
});

the below code in above function is works for date validation

$(“#RequisitionDate”).rules(‘add’, { lessThanOrEqualToCurrentDate: [new Date().toDateString(), “Requisition Date must be less than or equal to today.”] });

code for textbox of date

@Html.TextBoxFor(t => t.RequisitionDate, new { @class = “textEntry” })

“RequisitionDate” is nothing but an property for date
which is coming from .cs file of model

code fron .cs file

[Required(ErrorMessage = “Please enter Requisition date”)]
public DateTime RequisitionDate { get; set; }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s