Im trying to get the values from my datepicker into a new script which should validate that the second chosen value from datepicker is not before the first chosen datepicker.
However, my script won’t execute.
This is my view:
<div class="editor-field">
@Html.TextBox("PlannedDate", Model.PlannedDate, new { @class = "date", @readonly = "readonly" })
@Html.TextBox("CompletedDate", Model.CompletedDate, new { @class = "date", @readonly = "readonly" })
@Html.ValidationMessageFor(model => model.CompanyName)
</div>
<input id="submitfloat" type="submit" value="Go" />
This is my Script
<script>
$(".date").datepicker();
$('#submitfloat').submit(function() {
var fromDate = $('#PlannedDate').val();
var EndDate = $('#CompletedDate').val();
if (Date.parse(fromDate) > Date.parse(EndDate)) {
alert("Date error")
}
return false;
});
However, when I start debug ut Firebug, it seems like my line $('#submitfloat').submit(function() { wont execute.
Anyone know what my problem is and how it can be solved? Thanks in advance
well my first answer, i hope it help you.
first my view:
i use that for the date picker and the validation
now the script
i added a method to the jquery validate for the date Validation then i use it as a rule in the validation script