I have a enum in my C# code and i want to get names from enum in my jQuery validate 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 make something like this:
"config.EnumFormat[" + item + "].Start": {
required: true,
digits: true,
range: [1, 200]
}
In C# I can get names in this way:
foreach (var item in Enum.GetNames(typeof(EnumItemField)))
How can I make it in javascript? Thanks for advice!