ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
how to highlight the dropdown if none of the value is selected
Title:
B
I
{code}
?
@Html.Awe().AjaxDropdownFor(model => model.ProjectName).Url(Url.Action("GetProject", "GetData")).CssClass("form-control") In this dropdown, how do I change the background-color to red or high light the dropdown field if none of the value is selected from the dropdown.
Save Changes
Cancel
test
asked at 05 Aug 2016
Answers
B
I
{code}
?
in utils.js find "$.validator.setDefaults", and make it look like this: (I assume you're calling utils.init in _Layout.cshml like in minsetup demo) $.validator.setDefaults({ ignore: [], highlight: function (element, error, valid) { $(element).closest(".awe-field").addClass(error); }, unhighlight: function (element, error, valid) { $(element).closest(".awe-field").removeClass(error); } }); after this, whenever a control is invalid, its outer div (.awe-field) will have the input-validation-error css class so for an ajaxdropdown you could write some css like this: .input-validation-error select { background: red; }
Save Changes
Cancel
Omu
answered at 05 Aug 2016
how do I check the control is invalid.
at 05 Aug 2016
test
Along with the message I also want to highlight the dropdown field with red background.
at 05 Aug 2016
test
have a look at this demo: http://demo.aspnetawesome.com/Unobtrusive, with the changes from this answer you would also highlight the dropdown
at 05 Aug 2016
Omu
Where can I see the code for this demo.
at 05 Aug 2016
test
you can download it
at 05 Aug 2016
Omu
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK