I have two dropdowns created using HTML helpers, however i am not entirely sure on where i could add additional attributes to these two helpers? More specifically, i want to add an "onblur" attribute that calls a javascript function, as follows:
@onblur = "validate3(1)"
I want to be able to give the following HTML Helper dropdowns the above attribute:
@Html.DropDownList("ExpMonth", new List
{
new SelectListItem { Text = "01", Value = "1"},
new SelectListItem { Text = "02", Value = "2"},
new SelectListItem { Text = "03", Value = "3"},
new SelectListItem { Text = "04", Value = "4"},
new SelectListItem { Text = "05", Value = "5"},
new SelectListItem { Text = "06", Value = "6"},
new SelectListItem { Text = "07", Value = "7"},
new SelectListItem { Text = "08", Value = "8"},
new SelectListItem { Text = "09", Value = "9"},
new SelectListItem { Text = "10", Value = "10"},
new SelectListItem { Text = "11", Value = "11"},
new SelectListItem { Text = "12", Value = "12"}
}, "MM")
@Html.DropDownList("ExpYear", new List
{
new SelectListItem { Text = "2020", Value = "1"},
new SelectListItem { Text = "2021", Value = "2"},
new SelectListItem { Text = "2022", Value = "3"},
new SelectListItem { Text = "2023", Value = "4"},
new SelectListItem { Text = "2024", Value = "5"},
new SelectListItem { Text = "2025", Value = "6"},
new SelectListItem { Text = "2026", Value = "7"},
new SelectListItem { Text = "2027", Value = "8"},
new SelectListItem { Text = "2028", Value = "9"},
new SelectListItem { Text = "2029", Value = "10"},
new SelectListItem { Text = "2030", Value = "11"},
}, "YY")
Any help is appreciated.