Click here to Skip to main content
16,016,623 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have used this after when i click on button that will display message and go to the view
<script type="text/javascript">

$(document).ready(function () {
$("#btnSubmit").click(function () {

var sYear = $("#startIDs").val();
var eYear = $("#endID").val();

if (eYear > sYear) {
alert("Please ensure that the End Date is greater than to the Start Date.");



}
});
});
</script>

@Html.DropDownListFor(m => m.endID, new SelectList(Model.EndGetYears, "endID", "PledgeYear"), new { @Class = "ddlsmall" })

@Html.DropDownListFor(m => m.CampaignTypeId, new SelectList(Model.GetCampaignType, "CampaignTypeId", "description"), "All", new { @Class = "ddllarge" })


<input type="submit" id="btnSubmit" value="Generate Report" class="ActionButton"
/>

Please tell me how to resolve it.
Posted
Updated 8-Aug-13 2:01am
v5
Comments
DGKumar 8-Aug-13 7:48am    
Thank you very much it is very useful to my requirement.
DGKumar 8-Aug-13 7:57am    
I have used this after when i click on button that will display message and go to the view
<script type="text/javascript">

$(document).ready(function () {
$("#btnSubmit").click(function () {

var sYear = $("#startIDs").val();
var eYear = $("#endID").val();

if (eYear > sYear) {
alert("Please ensure that the End Date is greater than to the Start Date.");



}
});
});
</script>

@Html.DropDownListFor(m => m.endID, new SelectList(Model.EndGetYears, "endID", "PledgeYear"), new { @Class = "ddlsmall" })

@Html.DropDownListFor(m => m.CampaignTypeId, new SelectList(Model.GetCampaignType, "CampaignTypeId", "description"), "All", new { @Class = "ddllarge" })


<input type="submit" id="btnSubmit" value="Generate Report" class="ActionButton"
/>

Please tell me how to resolve it.
harshal7689 9-Aug-13 1:44am    
you need the text of dropdownlist.

var sYear = $("#startIDs").text();
var eYear = $("#endID").text();

or you can go to this links, i hope it is useful to you
http://stackoverflow.com/questions/1888931/set-dropdown-value-by-text-using-jquery

http://stackoverflow.com/questions/13613193/how-to-compare-dropdownlist-text-with-static-string

1 solution

JavaScript
function Yearcompare()
{
var year1=$("#dropdownlistboxes1").val();
var year2=$("#dropdownlistboxes2").val();

if(year1 < year2){
alert("Start year must < than end year");
}
}

Call this Function on your dropdownlistboxes1 on change event.

HTML
<select id="dropdownlistboxes1"  önchange="Yearcompare()" name="xxx">
</select>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900