I have an enumeration in C # code and I want to get the names from enum in my jQuery validation rules.
Enum:
public enum EnumItemField { Zero = 0, One = 1, Two = 2, Three = 3, Four = 4, Five = 5, }
Validate:
function updateFieldStatus() { } $(document).ready(function () { $("#IntegrationService").validate({ rules: { //Set range of Start "config.EnumFormat[Zero].Start": { required: true, digits: true, range: [1, 200] }, "config.EnumFormat[One].Start": { required: true, digits: true, range: [1, 200] }, }, submitHandler: function () { MsgBoxService.show({ //setId: "saveload", //objectId: "asrun" }); }, });
This really works, but I want to do something like this:
"config.EnumFormat[" + item + "].Start": { required: true, digits: true, range: [1, 200] }
In C #, I can get the names this way:
foreach (var item in Enum.GetNames(typeof(EnumItemField)))
How can I do this in javascript? Thanks for the advice!